954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Do while Loop to display a choosen month and the dates in it

This is the days of January


<%
varRowCount = 1
varTodayDate = day(now())
varTodayMonth = MonthName(month(date())
Response.Write "Report for " & varTodayMonth & ""
Do While varMonthCount <32 or <= 31
Response.Write "The days of " & varTodayMonth & " " & varRowCount
Response.Write ": are varTodayDate
"
varRowCount = varRowCount + 1
Loop
%>

jchamel
Newbie Poster
7 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
 

The problem is here:

You have:

<%
varRowCount = 1
varTodayDate = day(now())
varTodayMonth = MonthName(month(date())
Response.Write "<h2>Report for " & varTodayMonth & "</h2>"
Do While varMonthCount <32 or <= 31
Response.Write "The days of " & varTodayMonth & " " & varRowCount
Response.Write ": are varTodayDate"
varRowCount = varRowCount + 1
Loop
%>


It should be:

<%
varRowCount = 1
varTodayDate = day(now())
varTodayMonth = MonthName(month(date())
Response.Write "<h2>Report for " & varTodayMonth & "</h2>"
Do While varMonthCount <32 or varMonthCount  <= 31
Response.Write "The days of " & varTodayMonth & " " & varRowCount
Response.Write ": are varTodayDate"
varRowCount = varRowCount + 1
Loop
%>
Cyber-SEO
Newbie Poster
10 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
 

Or you can make it a bit more dynamic by allowing the user to select the month and then display the days in that month, as below:

<form>
<select size="1" name="Month">
<option value="January">Jan</option>
<option value="February">Feb</option>
<option value="March">Mar</option>
<option value="April">Apr</option>
<option value="May">May</option>
<option value="June">Jun</option>
</select>
<input type="submit" value="Choose Month">
</form>
<%
dim intDay  '// incremental number used in the loop
dim daysInMonth '// the number of days in each month
dim strMonth '// the selected month

intDay = 1 '// set the value to 1 to start
strMonth = request("month") '// set the month to the one selected in the form

If strMonth <> "" Then '// If a month has been selected display the results

 '// assign the number of days to each month
Select Case strMonth
Case "January", "March", "May", "July", "August", "October", "December"
 daysInMonth = 31
Case "February"
 daysInMonth = 28
Case Else
 daysInMonth = 30
End Select

'// Display the total number of days in the selected month
Response.Write "The days of " & strMonth & " are "
'// Then loop through the days in the month, starting at 1
Do While intDay <= daysInMonth
 Response.Write intDay & ", "
 intDay = intDay + 1
Loop 

Else '// there has been no month selected so....
' do nothing
End If 
%>
Lafinboy
Junior Poster
172 posts since Jul 2004
Reputation Points: 16
Solved Threads: 7
 

[QUOTE=Lafinboy]Or you can make it a bit more dynamic by allowing the user to select the month and then display the days in that month, as below:

Thanks so much you have been so much help to me. YOUR GREAT!

jchamel
Newbie Poster
7 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You