Finish business before

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 mine Exit Selectgives an error Expected: Do or For or Sub or Function or Property. I know, not really. Should I use something else? I could just use the instructions ifand not leave the case earlier, but for this I would need to duplicate the code that I want to avoid. Any help would be really appreciated.

Update

I tried to change Exit Selectto End Selectand got an error End Select without Select Case. It is definitely within Select Caseand End Select.

+3
source share
4 answers

VB has no way to exit the block Select. Instead, you need to make the content conditional, perhaps by inverting your Exit Selectconditional.

Select case Case 

case "Case0" 
... 

case "Case1" 
  If Not Condition Then 
    *Perform action* 
  End If 

case "Case2" 
... 

End Select 

.

+6

VB6 Exit Select - VB.NET

Exit Statement - Exit Select

- select , Exit Sub

+4

Unfortunately, VB6 has no offer Exit Select.

It is available on VB.NET!

+1
source

try it

Do
    Select case Case

    case "Case0"
    ...

    case "Case1"
      if Condition Then
         Exit Do
      End If
      *Perform action*

    case "Case2"
    ...

    End Select
Loop While False

Edit: Btw, I would not hesitate to use GoToin this case (and not only that).

+1
source

All Articles