Solved

Easy Question!!!!!

Posted on 2000-03-21
4
201 Views
Last Modified: 2010-05-02
In Delphi we can write :

For cpt := 1 to 10 do
begin
  if (condition) then
    continue; //bypass (do something)
  (do something)
end;

How can I do this with VB????
0
Comment
Question by:HellSlayer
  • 2
4 Comments
 
LVL 2

Expert Comment

by:Jagar
ID: 2641495
for p = 1 to 10
   if (condition) then
      exit for
   end if
next p
0
 
LVL 2

Accepted Solution

by:
Jagar earned 200 total points
ID: 2641502
That was supposed to be an answer.
You could also do p = 11 in between if and end if.  If you want the program to execute the rest of the for statement until it gets back to the for statement.
0
 

Author Comment

by:HellSlayer
ID: 2641555
I don't realy want to "Exit" the For.
I just want to jump to the next value...
0
 

Expert Comment

by:rdolivaw
ID: 2641561
Try:

For cpt = 1 to 10
  If Not (condition) then
      (do something)
  End If
Next cpt

This will (do something) each time (condition) is false.

Or, if you need to drop out of the For/Next loop when (condition):

For cpt = 1 to 10
   If (condition) then
      Exit For
   End If
   (do something)
Next cpt

This will (do something) until (condition) is true.

Variation:

   If Not (condition) then
       (do something)
   Else
      Exit For
   End If
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBS file using code from 2nd file (txt or vbs) 4 44
MS SQL store procedure to calculate and return result 6 63
How to make an ADE file by code? 11 94
Problem to With line 4 63
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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

820 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