need to get out of the select case
We are using a code where we need to select an it开发者_开发百科em in combobox, we do this by a select case statement like Case "SelectItem" However if there are no items in the combobox the code should exit from the case."End Select" was not working..
How can we resolve the same? is there a different logic?
you could try using Case Else
to handle any unexpected values.
Select Case SelectItem
Case 1
'There is one item in the combobox
Case 2
'There are two items in the combobox
Case Else
'There are a different number of items
End Select
Not sure what exactly you are doing. You could also wrap your Select
in an If
statement.
If Combobox.Listcount > 0 Then
Select Case SelectItem
Case <Item>
'Do something here
End Select
End If
Unfortunately I don't think there is that functionality. One way to get around it would be to put your Select
inside it's own sub and then you can exit it with Exit Sub
/Exit Function
.
I'm not sure I entirely understand what you are asking, but I think you may be able to achieve what you want just by putting your select block inside of an if-then. i.e.
If Combobox.Listcount > 0 Then
Select Case ...
Case ...
...
End Select
End If
精彩评论