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
8
Medium Priority
?
195 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
[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
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 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

by:hxb
ID: 2549631
pjknibbs,

Your answner is OK.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

610 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