'========================================
'函数名称:CalcDate
'函数功能:产生日历数组
'参 数:arrDate要返回的数组
'返 回 值:无
'作 成:D.Densin
'日 期:2007-4-24 03:23:25
'========================================
Sub CalcDate(arrDate,dteSYS)
Dim l_strFirstDay '当月第一天
Dim l_strLastDay '下月第一天
Dim l_intCountDay '总天数
Dim l_loopi,l_loopj '循环变量
Dim l_TempX,l_TempY '临时变量
'参数控制,如果不传递指定日期,则使用WEB SERVER上的时间.
If dteSYS = "" Or IsNull(dteSYS) Then
dteSYS = Now()
Else
If Not IsDate(dteSYS) Then
Response.Write "产生日历数组函数,第二参数错误!"
Response.End()
End If
End If
'取得基础的参照日期.
l_strFirstDay=Cdate(Year(dteSYS)& "-" &Month(dteSYS) & "-01")
l_strLastDay =DateAdd("m",1,l_strFirstDay)
l_intCountDay = DateDiff("d",l_strFirstDay,l_strLastDay)
'初始化数组,确定当月有多少周
ReDim arrDate(6,4)
'循环计算每一天在数组中的位置.
For l_loopi=0 To l_intCountDay-1
l_TempX=Cint(Weekday(DateAdd("d",l_loopi,l_strFirstDay),3)) mod 7
'防止1号刚好是星期日时产生进位导致的数组Y轴超界.
If Weekday(l_strFirstDay,3)<>7 Then
l_TempY=Fix((Weekday(l_strFirstDay,3) + l_loopi)/7)
Else
l_TempY=Fix(l_loopi/7)
End If
If l_TempY > Ubound(arrDate,2) Then
ReDim Preserve arrDate(6,l_TempY)
End If
arrDate(l_TempX,l_TempY)=l_loopi+1
Next
End Sub
'函数名称:CalcDate
'函数功能:产生日历数组
'参 数:arrDate要返回的数组
'返 回 值:无
'作 成:D.Densin
'日 期:2007-4-24 03:23:25
'========================================
Sub CalcDate(arrDate,dteSYS)
Dim l_strFirstDay '当月第一天
Dim l_strLastDay '下月第一天
Dim l_intCountDay '总天数
Dim l_loopi,l_loopj '循环变量
Dim l_TempX,l_TempY '临时变量
'参数控制,如果不传递指定日期,则使用WEB SERVER上的时间.
If dteSYS = "" Or IsNull(dteSYS) Then
dteSYS = Now()
Else
If Not IsDate(dteSYS) Then
Response.Write "产生日历数组函数,第二参数错误!"
Response.End()
End If
End If
'取得基础的参照日期.
l_strFirstDay=Cdate(Year(dteSYS)& "-" &Month(dteSYS) & "-01")
l_strLastDay =DateAdd("m",1,l_strFirstDay)
l_intCountDay = DateDiff("d",l_strFirstDay,l_strLastDay)
'初始化数组,确定当月有多少周
ReDim arrDate(6,4)
'循环计算每一天在数组中的位置.
For l_loopi=0 To l_intCountDay-1
l_TempX=Cint(Weekday(DateAdd("d",l_loopi,l_strFirstDay),3)) mod 7
'防止1号刚好是星期日时产生进位导致的数组Y轴超界.
If Weekday(l_strFirstDay,3)<>7 Then
l_TempY=Fix((Weekday(l_strFirstDay,3) + l_loopi)/7)
Else
l_TempY=Fix(l_loopi/7)
End If
If l_TempY > Ubound(arrDate,2) Then
ReDim Preserve arrDate(6,l_TempY)
End If
arrDate(l_TempX,l_TempY)=l_loopi+1
Next
End Sub