So I have something like the following in Vb6;
Select case Case
case "Case0"
...
case "Case1"
if Condition Then
Exit Select
End If
*Perform action*
case "Case2"
...
End Select
But for some reason my Exit Select
throws the error Expected: Do or For or Sub or Function or Property
. I know, not pretty. Should I be using something else? I could just use if
statements and not exit the case early, but this would require duplicate code, which I want to avoid. Any help would be really appreciated.
Update
Tried changing Exit Select
to End Select
and got the error End Select without Select Case
. It is definitely within a Select Case
and an End Select
.
VB doesn't have a facility to exit a Select
block.
Instead, you'll need to make the contents conditional, possibly inverting your Exit Select
conditional.
Select case Case
case "Case0"
...
case "Case1"
If Not Condition Then
*Perform action*
End If
case "Case2"
...
End Select
Which will have exactly the same end result.
There is no Exit Select
Statement in VB6 - only VB.NET
Have a look at the language reference for the Exit Statement - there is no mention of Exit Select
Best option is to refactor your select statements into a new subroutine and then just Exit Sub
Unfortunately, VB6 doesn't have the Exit Select
clause available.
This is ony available in VB.NET!
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