Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C/C++ 'continue' Equivalent in VB6

Tags:

Is there a VB6 equivalent to the C/C++ 'continue' keyword?

In C/C++, the command 'continue' starts the next iteration of the loop.

Of course, other equivalents exist. I could put the remaining code of the loop in an if-statement. Alternatively, I could use a goto. (Ugh!)

like image 642
Steven Avatar asked May 06 '09 18:05

Steven


People also ask

What is continue statement in Visual Basic?

In visual basic, the Continue statement is useful to transfer the control immediately to the next iteration of loops such as For, While, Do-While from the specified position by skipping the remaining code.

What is for next loop in VB?

A For Next loop is used to repeatedly execute a sequence of code or a block of code until a given condition is satisfied. A For loop is useful in such a case when we know how many times a block of code has to be executed.

How do you break a loop in Visual Basic?

When used within nested Do loops, Exit Do exits the innermost loop and transfers control to the next higher level of nesting. Immediately exits the For loop in which it appears. Execution continues with the statement following the Next statement. Exit For can be used only inside a For ...


2 Answers

There is no equivalent in VB6, but later versions of VB do introduce this keyword. This article has a more in-depth explanation: http://vbnotebookfor.net/2007/06/04/the-continue-statement/

Perhaps you can restructure your code to either add an if statement or have the loop just call a function that you can return from.

like image 108
Justin Ethier Avatar answered Sep 20 '22 21:09

Justin Ethier


VB6 has no continue statement for loops. You have to emulate it using goto, if, or another loop.

//VB.net do     if condition then continue do     ... loop //VB6 equivalent (goto) do     if condition then goto continue_do     ... continue_do: loop //VB6 equivalent (if) do     if not condition then         ...     endif loop 

You can not use "exit while" in VB6. But you can use goto.

While condition      if should_skip then goto mycontinue      'code      if should_break then goto outloop     mycontinue:  Wend  outloop: 
like image 26
Craig Gidney Avatar answered Sep 20 '22 21:09

Craig Gidney