Loop with For Next in classic ASP

Asked

Viewed 246 times

0

I need to make a loop where I have the current year 2019, but I want to show the next 10 years from this date using a loop, with this result ex:

2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029

I know a basic loop would be like this :

For data = 1 To 12
   response.write( data + 1 & "<br />")
Next

But I want to know a way where you take it directly from date, as the years pass by the dates will also change.

Obs.: in classic ASP.

1 answer

1


Do so:

<%
for data = year(now) to year(now)+10
   response.write data &"<br>"
next
%>

The year(now) take the current year.

The code above will print:

2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029

Browser other questions tagged

You are not signed in. Login or sign up in order to post.