|
编了个函数,没完全测试,按星期一到星期天为一个星期
Private Sub Form_Load()
Dim MyDate
MyDate = #6/30/2006#
MsgBox MyWeek(MyDate)
End Sub
Function MyWeek(MyDay) As Integer
Dim FirstWeek As Integer
Dim IntWeek As Integer
Dim TotalWeek As Integer
FirstWeek = Weekday(CDate(Format(MyDay, "yyyy-mm-1")), vbMonday)
If FirstWeek = 7 Then
IntWeek = 1
Else
If (7 - FirstWeek) > 0 Then
IntWeek = 1
Else
IntWeek = 0
End If
End If
If (Format(MyDay, "d") - 1) >= 7 - FirstWeek Then
If (Format(MyDay, "d") - FirstWeek) Mod 7 = 0 Then
TotalWeek = Fix((Format(MyDay, "d") - FirstWeek) / 7) + IntWeek
Else
TotalWeek = Fix((Format(MyDay, "d") - FirstWeek) / 7) + IntWeek + 1
End If
Else
TotalWeek = 1
End If
MyWeek = TotalWeek
End Function
|
|