today = now
mm = month(today)
yy = year(today)
for ii = 1 to 18
WScript.Echo MonthName(mm, true) & " " & cstr(yy)
mm = mm + 1
if mm > 12 then
mm = 1
yy = yy + 1
end if
next
Rather than manually increment through the month and year, why not allow the DateAdd function to do it for you?
Code:
Dim tdate, i
tdate = Now()
For i = 1 to 18
tdate = DateAdd("m",1,tdate)
Response.Write MonthName(Month(tdate)) & " " & Year(tdate) & "<br/>"
Next
The downside of this function is that it is probably a little less efficient (a call ot Month() and Year() in every loop instead of using a variable for each), but it is more compact without losing it's readability.
-T
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.