Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# For .. Next

Posted on 2000-02-22
Medium Priority
195 Views
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
Question by:hxb
[X]
###### 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
• 2
• 2
• 2
• +2

LVL 12

Expert Comment

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

ID: 2549008
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

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

LVL 3

Expert Comment

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

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

ID: 2549135
marine

Tks for pointing it out to me

Ivanc
0

LVL 12

Accepted Solution

pjknibbs earned 150 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

ID: 2549631
pjknibbs,

0

## Featured Post

Question has a verified solution.

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

Iâ€™ve seen a number of people looking for examples of how to access web services from VB6.  Iâ€™ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web servâ€¦
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applicâ€¦
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â€¦
###### Suggested Courses
Course of the Month10 days, left to enroll