Android Question Case 0 to 10 , Case 11 to 20, Etc.. ?

ElliotHC

Active Member
Licensed User
I'm trying to find how to select case between values..

In VB it's

B4X:
Select Variable

Case 0 to 9
' Do something
Case 10 to 19
' Do Something
Case Else

End Select
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

ac9ts

Active Member
Licensed User
Longtime User
B4X:
Select True
  Case X<10
    'Do something
  Case X>=10 and X<20
    'Do something else
  Case X>=20
    'Do something completely different
End Select

This would also work. The Select will stop at the first statement that evaluates to True. I use this method a lot to prioritize events.
B4X:
Select True
  Case X<10
    'Do something
  Case X<20
    'Do something else
  Case Else
    'Do something completely different
End Select

You can also mix types as long as they evaluate to True or False
B4X:
Select True
  Case X<10
    'Do something
  Case strAnswer="Yes"
    'Do something
  Case X<20
    'Do something else
  Case Else
    'Do something completely different
End Select
 
Upvote 0
Top