Just wondering if there was a command that would rerun the Select Case.
e.g. Case a:
change Select Case value to next in array
rerun Select Case
somewhat recursive behaviour. Is this possible?
Just wondering if there was a command that would rerun the Select Case.
e.g. Case a:
change Select Case value to next in array
rerun Select Case
somewhat recursive behaviour. Is this possible?
If you place the select case in a method you can re-call the method from within.
This is recursive method calling.
Beware of stackoverflows
Another method that works is to put the “select case” into a loop:
Do
//Set next value to “s”
Select case s
case “0”
//Do something
case “1”
//Do something else
case else
//Unrecognised or end of data; we have finished
Exit
end select
Loop
(you have to be sure that the “case else” statement will ever be called).
And weird recursive nightmares if you work on recursive code too late into the evening.
Use loop control words like Continue
and Exit
to control an otherwise infinite loop.
Do
Select Case Foo
Case Bar
Continue ' jump to next iteration of the loop
Case Baz
Exit Do ' exit the loop
End Select
Loop
The lengths languages will goto, in order not to use goto.
(and I know its not quite the same)
What about
If UserCancelled Then Exit // ?
Since Exit alone doesn’t apply to Select Case blocks, both “Exit” and “Exit Do” do the same here.
If you want the user to be able to abort and exit your loop, you can add this at the appropriate place. However, that’s not required to exit a loop when your code decides all is done.