請問一下各位大大…怎麼寫一個可以算週數的程式呢…或是給我一個方向呢…
比如說…我想顯示2006年3月份的一個完整的月歷出來…
然後旁邊顯示三月的第一週是在這一整年的第9週…第二週是一整年的第10週…
或者看更後面的十二月的第一週是一整年的第49週…
謝謝嚕~
2006-03-23 14:58:04 · 2 個解答 · 發問者 Frank 1 in 電腦與網際網路 ➔ 程式設計
Dim WithEvents A As ComboBox, WithEvents B As ComboBoxPrivate Sub A_Click()Col A, BEnd SubPrivate Sub B_Click()Col A, BEnd SubPrivate Sub Form_Load()Dim I%Set A = Controls.Add("VB.ComboBox", "A")For I = 1966 To 2100 A.AddItem INextA.Visible = True: A = Year(Now)Set B = Controls.Add("VB.ComboBox", "B")For I = 1 To 12 B.AddItem INextB.Visible = True: B = Month(Now): B.Left = A.Width + 300Col A, BEnd SubSub Col(Y%, M%)Dim D%, I%, F%, W%, X%, S$D = Day(DateSerial(Y, M + 1, 0))AutoRedraw = True: Cls: ForeColor = vbBlackCurrentY = 720Print " ";For I = 1 To 7 ForeColor = Chg(I) Print WeekdayName(I) & " ";NextPrint 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 Print S; X = DateDiff("WW", CDate(Y - 1 & "/ 12 / 31"), DateSerial(Y, M, I), 2) If F = 7 Then ForeColor = 0: Print , "第"; X; "週"; Tab(1)NextIf Weekday(DateSerial(Y, M, D)) < 7 Then CurrentX = 5060: ForeColor = 0 Print "第"; X; "週"End IfAutoRedraw = FalseEnd SubFunction Chg(N)Chg = vbBlackIf N = 7 Then Chg = vbGreenElseIf N = 1 Then Chg = vbRedEnd IfEnd Function
2006-03-24 13:16:40 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋
使用MonthView控制項,並將"Show Week Numbers"屬性設為True。
2006-03-23 18:51:08 · answer #2 · answered by ? 2 · 0⤊ 0⤋