Class calendar
Dim calendarmonth, calendaryear, calendarday
Dim today
Dim table1
Dim todayw
set rs=server.createobject("adodb.recordset")
Private Sub Class_Initialize
today = Date
Set table1 = document.getElementById("calendartable")
End Sub
Function tableclear()
rowsnum = 1
j = 0
For i = 0 To 41
table1.rows(rowsnum).cells(j).innerText = ""
j = j + 1
If j = 7 Then
j = 0
rowsnum = rowsnum + 1
End If
Next
End Function
Public Property Get thedayd()
If Len(calendarday) = 0 Then
calendarday = Day(today)
End If
theyeard = calendaryear
End Property
public property set thedate(sql)
rs.open sql1,conn,1,3
thedate=rs
end property
Public Property Let thedayd(theday)
calendarday = theday
End Property
Public Property Get theyeard()
If Len(calendaryear) = 0 Then
calendaryear = Year(today)
End If
theyeard = calendaryear
End Property
Public Property Get themonthd()
If Len(calendarmonth) = 0 Then
calendarmonth = Month(today)
End If
themonthd = calendarmonth
End Property
Public Property Let theyeard(theyear)
calendaryear = theyear
End Property
Public Property Let themonthd(themonth)
calendarmonth = themonth
End Property
Function displayDay()
Dim days, theday
Dim d
Dim rows
Dim cells
rows = 1
d = calendaryear&"-"&calendarmonth&"-"&"1"
todayw = Weekday(d)
Select Case calendarmonth
Case 1
days = 31
Case 2
days = runnian(calendaryear)
Case 3
days = 31
Case 4
days = 30
Case 5
days = 31
Case 6
days = 30
Case 7
days = 31
Case 8
days = 31
Case 9
days = 30
Case 10
days = 31
Case 11
days = 30
Case 12
days = 31
End Select
rowsnum = 1
j = todayw -1
For i = 1 To days
table1.rows(rowsnum).cells(j).innerText = i
j = j + 1
If j = 7 Then
j = 0
rowsnum = rowsnum + 1
End If
Next
End Function
Function runnian(theyear)
If theyear Mod 100 = 0 Then
If theyear Mod 4 = 0 Then
runnian = 29
Else
runnian = 28
End If
Else
If theyear Mod 4 = 0 Then
runnian = 29
Else
runnian = 28
End If
End If
End Function
Function addrecord(rowsnum, cellsnum, showday)
showday = Replace(showday, "\", "/")
showday = "file:///"&showday
table1.rows(rowsnum -1).cells(cellsnum).innerHTML = "<a href='"&showday&"'>"&table1.rows(rowsnum -1).cells(cellsnum).innerHTML&"</a>"
End Function
End Class
实际上我如上程序本来是没有set的,只不过为了配合说明set和let的不同之处写的
调用的时候用set ttt=new class ttt.thedata-----这个就相当于一个rs对象了