Easy Question!!!!!

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

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

How can I do this with VB????
Question by:HellSlayer
  • 2

Expert Comment

ID: 2641495
for p = 1 to 10
   if (condition) then
      exit for
   end if
next p

Accepted Solution

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.

Author Comment

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

Expert Comment

ID: 2641561

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.


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

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA color chart bars 12 86
VB6 Compile Compatibility Issue 4 102
Determine Range to Select 5 48
Run code from text file in vb 1 65
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

803 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