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!)
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.
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.
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 ...
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.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With