|
5#
楼主 |
发表于 2008-12-20 20:07:28
|
只看该作者
感谢各位老师指点与辩论,有启发,www.office-cn.net网站就是好啊,能与这么多网友一起讨论学习ACCESS,为感谢各位,也献上一段代码,是如何判断一个时间段内经历多少个工作日.
函数源于明日科技
Private Function gongzuori(ByVal d1 As Date, ByVal d2 As Date)
Dim i As Date
Dim num As Integer
For i = CDate(d1) To CDate(d2)
If Weekday(i, vbMonday) <> 7 And Weekday(i, vbMonday) <> 6 Then
num = num + 1
End If
Next i
gongzuori = num
End Function
调用
Private Sub Command1_Click()
If IsDate(Text1) = True And IsDate(Text2) = True Then
Dim i As Integer
i = gongzuori(CDate(Text1), CDate(Text2))
Label3.Caption = "经历" & i & "个工作日"
Else
MsgBox "请输入日期型"
End If
End Sub |
|