Solved

For .. Next

Posted on 2000-02-22
8
186 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

by:ivanc
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 6

Expert Comment

by:Marine
Comment Utility
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
Comment Utility
marine

Tks for pointing it out to me

Ivanc
0
 
LVL 12

Accepted Solution

by:
pjknibbs earned 50 total points
Comment Utility
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
Comment Utility
pjknibbs,

Your answner is OK.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now