Select Case (Vb to B4A)

ciginfo

Well-Known Member
Licensed User
Longtime User
Bonjour.
How to code this with B4A ??

Thank you

Dim x as int
Select x
x > 5
Label1.Text = "Plus grand que 5"
x < 5
Label1.Text = "Plus petit que 5"
End select
 

ciginfo

Well-Known Member
Licensed User
Longtime User
Oui bien sur, mais j'ai plusieurs conditions et avec VB le Select case est plus pratique.
Conditions :
If x >5 and x <10
If x >10 and x <15
If x >15 and x <20
If x >20 and x <25
If x >25 and x <30
etc..
Tant pis je vais faire avec If ... Then...

Merci beaucoup pour a rapidité de ces réponses
 
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
If your steps are 5 at a time try dividing by 5:
B4X:
Dim temp As Double
temp = Floor (x/5)
Select temp
Case 0 ' x was less than 5
Label1.Text = "Plus petit que 5"
Case 1 ' x was between 5 and 10
Label1.Text = "Plus grand que 5"
End select

Extend as needed
 
Upvote 0

Djembefola

Active Member
Licensed User
Longtime User
You can use Select Case True


B4X:
Select Case true
Case (x<5)
Label1.Text = "Plus petit que 5"
Case Else
Label1.Text = "Plus grand que 5"
End Select
 
Upvote 0
Top