Solved

Easy Question!!!!!

Posted on 2000-03-21
4
194 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Adding to a VBA? 6 49
MS Date Picker 64 bit 32 bit issue 12 43
VBA Shell can't Find Word document 11 46
Visual Studio 2005 text editor 10 23
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…

743 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

11 Experts available now in Live!

Get 1:1 Help Now