The 'For..Next' Statement

Posted on 2003-02-20
Medium Priority
Last Modified: 2012-05-04
As far as I know,this is how the 'For..Next' statement works:
For i=1 to 5
Next i

What I want to do now is:
For i=5 to i=1

Next i

Of course this does not work, I want to do a down count from 5 to 1. Any suggestions on how to do that??
Question by:VivienW
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 13

Accepted Solution

AlbertaBeef earned 140 total points
ID: 7991532
for i = 5 to 1 step -1
next i

Expert Comment

ID: 7991592
yep. that will do it

Expert Comment

ID: 7991737
another one is this

for i = 1 to 5
j = 6 - i

next i

Expert Comment

by:Naveen Swamy
ID: 7991873
AlbertaBeef is right

Expert Comment

ID: 7991887
Answers above are correct.  Be careful with the "next i".  As you know it will add one to "i" when you want to count down.  If you use either of the codes directions above, this will not be an issue.  However, if you choose one of the many other solution to this question, it could be.


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question