Hi,
I am writing a calendar and it works roughly as follows:
1. Build a string called FirstDay which is 01 & "/" & TheMonth & "/" & TheYear.
2. Work out what day of the week this is and set a value for a variable called counter
3. Pass the value of counter to a function that builds a string consisting of counter & "/" & TheMonth & "/" & TheYear
4. If the string created in step 3 is a valid date then display it.
My calendar was behaving a bit unusally so I stripped out all the code to the bear minimum and what I have found is that the function is called and does create the string 01/09/2008 but for some reason is not returning it to the main program. On the 2nd loop and onwards it does work however. Can anyone see where I'm going wrong?
<%
TheMonth=9
TheYear=2008
FirstDay="01" & "/" & TheMonth & "/" & TheYear
Select Case WeekDay(FirstDay)
Case 1
counter=2
Case 2
counter=1
Case 3
counter=0
Case 4
counter=-1
Case 5
counter=-2
Case 6
counter=-3
Case 7
counter=3
End Select
Select Case TheMonth
Case 1, 3, 5, 7, 8, 10, 12
DaysInMonth=31
Case 4, 6, 9, 11
DaysInMonth=30
Case 2
DaysInMonth=28
End Select
If TheMonth=2 And (TheYear/4)=Int(TheYear/4) Then DaysInMonth=29
Function GetEventDate(counter)
If counter>0 And counter<=DaysInMonth Then
eventdate=""
If counter<10 Then
eventdate=eventdate&"0"
End If
eventdate=eventdate&counter & "/"
If TheMonth<10 Then
eventdate=eventdate & "0"
End If
eventdate=eventdate & TheMonth & "/" & TheYear
Else
eventdate=""
End If
End Function
For i=1 To 31
Response.Write(counter) & ":"
GetEventDate(counter)
Response.Write(eventdate)
Response.Write("<br>")
counter=counter+1
Next
%>
Thanks very much
Ed
I am writing a calendar and it works roughly as follows:
1. Build a string called FirstDay which is 01 & "/" & TheMonth & "/" & TheYear.
2. Work out what day of the week this is and set a value for a variable called counter
3. Pass the value of counter to a function that builds a string consisting of counter & "/" & TheMonth & "/" & TheYear
4. If the string created in step 3 is a valid date then display it.
My calendar was behaving a bit unusally so I stripped out all the code to the bear minimum and what I have found is that the function is called and does create the string 01/09/2008 but for some reason is not returning it to the main program. On the 2nd loop and onwards it does work however. Can anyone see where I'm going wrong?
<%
TheMonth=9
TheYear=2008
FirstDay="01" & "/" & TheMonth & "/" & TheYear
Select Case WeekDay(FirstDay)
Case 1
counter=2
Case 2
counter=1
Case 3
counter=0
Case 4
counter=-1
Case 5
counter=-2
Case 6
counter=-3
Case 7
counter=3
End Select
Select Case TheMonth
Case 1, 3, 5, 7, 8, 10, 12
DaysInMonth=31
Case 4, 6, 9, 11
DaysInMonth=30
Case 2
DaysInMonth=28
End Select
If TheMonth=2 And (TheYear/4)=Int(TheYear/4) Then DaysInMonth=29
Function GetEventDate(counter)
If counter>0 And counter<=DaysInMonth Then
eventdate=""
If counter<10 Then
eventdate=eventdate&"0"
End If
eventdate=eventdate&counter & "/"
If TheMonth<10 Then
eventdate=eventdate & "0"
End If
eventdate=eventdate & TheMonth & "/" & TheYear
Else
eventdate=""
End If
End Function
For i=1 To 31
Response.Write(counter) & ":"
GetEventDate(counter)
Response.Write(eventdate)
Response.Write("<br>")
counter=counter+1
Next
%>
Thanks very much
Ed