求一個數入年月由pic顯示出當月月曆的程式
2006-02-14 16:02:28 · 2 個解答 · 發問者 Elizabeth 1 in 電腦與網際網路 ➔ 程式設計
'表單置1個PictureBox跟CommandButton
Private Sub Command1_Click()
Dim Y As Integer, M As Integer, D As Integer, I As Integer, F As Integer, W As Long, S As String
Do
Y = Val(InputBox("請輸入年份(西元)"))
If Y = 0 Then Exit Sub
Loop Until Y > 0
Do
M = Val(InputBox("請輸入月份"))
If M = 0 Then Exit Sub
Loop Until M > 0 And M < 13
D = Day(DateSerial(Y, M + 1, 0))
With Picture1
.FontName = "細明體": .AutoRedraw = True: .Cls: .ForeColor = vbBlack
Picture1.Print Y; "年"; M; "月"; Tab(1)
Picture1.Print " ";
For I = 1 To 7
.ForeColor = Chg(I)
Picture1.Print WeekdayName(I) & " ";
Next
Picture1.Print Tab(1): W = .TextWidth(" 星期一")
For I = 1 To D
S = I: F = Weekday(DateSerial(Y, M, I)): .ForeColor = Chg(F)
Do
S = " " & S
If I = 1 Then
If .TextWidth(S) >= (((F - 1) Mod 7) + 1) * W Then Exit Do
Else
If .TextWidth(S) >= W Then Exit Do
End If
Loop
Picture1.Print S;
If F = 7 Then Picture1.Print Tab(1)
Next
.AutoRedraw = False
End With
End Sub
Function Chg(N)
Chg = vbBlack
If N = 7 Then
Chg = vbGreen
ElseIf N = 1 Then
Chg = vbRed
End If
End Function
2006-02-14 23:43:33 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋
使用這個程式
我發現:
用民國年代和西元年待(實際上同年)輸入同月份
日期一模一樣
今天95/2/19使用
第一次輸入95年(民國)2月
19號是星期日(正確)
第二次輸入2006年2月
也是一樣喔
2006-02-19 13:40:45 · answer #2 · answered by andy135793726 5 · 0⤊ 0⤋