Solved

For .. Next

Posted on 2000-02-22
8
189 Views
Last Modified: 2010-05-02
VB6,
How to goto the next loop in
"For.. Next" and skip the other
code?

For example:
For i=1 to 100
   j=6
   k=10
   if blnYes=true then
     'Here how to skip the code
     ' of k=k+j ... and let it
     ' execute Next i?
   endif
   k=k+j
   
next i
0
Comment
Question by:hxb
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 12

Expert Comment

by:jgv
ID: 2548927
If blnYes = False Then k = k + j

or

If blnYes = True Then
   'do some code
Else
   k=k+j
End If

or use a 'goto'
0
 

Author Comment

by:hxb
ID: 2549008
Same question about
Do while true
Loop

I know I can use "If Then" and "GOTO"
But is there any other simple Code
such as "Loop" or Other Code I
can Use?


0
 
LVL 6

Expert Comment

by:Marine
ID: 2549067
Same applies to both do while and to For.
For i = 0 to 10
if i = 3 then
exit for
end if
next

i = 0
do while i < 10
 i = i + 1
 if i =5 then
   exit do
  end if
loop
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 3

Expert Comment

by:ivanc
ID: 2549117
HXB

I am not so sure about your qn but your syntax is slightly wrong.  it should be

For i =1 to 100
..
..
..
..
next

There should not be a next i

Hope this helps

Ivanc
0
 
LVL 6

Expert Comment

by:Marine
ID: 2549128
actually you can take that step out but there is nothing wrong
next i
just tells to pcocess next element.
0
 
LVL 3

Expert Comment

by:ivanc
ID: 2549135
marine

Tks for pointing it out to me

Ivanc
0
 
LVL 12

Accepted Solution

by:
pjknibbs earned 50 total points
ID: 2549515
One of the most annoying features of Visual BASIC is its lack of a CONTINUE option on For loops. The only way you can go to the next iteration of a loop is to insert a GOTO label, and put the label on the "NEXT" line of your loop. Maybe Microsoft will add this in version 7... <sigh>
0
 

Author Comment

by:hxb
ID: 2549631
pjknibbs,

Your answner is OK.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

770 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