Android Question Select Case help

RAJAN MBA

Member
Licensed User
Longtime User
What's wrong with this code? MMI is a double .The compiler suggest: ',' expected in select.
B4X:
Select MMI
Case 0.0 To 2.0
dist_txt="I. Instrumental - Generally not felt by people unless in favorable conditions"
Case 2.1 To 2.9
dist_txt=........
changing Case 0.0 To 2.0
to
Case 0.0, 2.0
shows 'Missing Parameter' error
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
You can't use 'To' in a Case statement, you would have to state each value separated by a ",":

B4X:
Select MMI
Case 0.0, 0.1,0.2,0.3 'etc
dist_txt="I. Instrumental - Generally not felt by people unless in favorable conditions"
End Select

It would be easier using If statements for this example.
B4X:
If MMI >= 0.00 Then
    If MMI <= 2.0 Then
        dist_txt="I. Instrumental - Generally not felt by people unless in favorable conditions"
    Else
        If MMI <= 2.9 Then
            dist_txt=........
        Else
            If MMI <= 3.9 Then
                'etc
            End if
        End If
    End if
End if
 
Upvote 0

RAJAN MBA

Member
Licensed User
Longtime User
Thanks stevel05.
I have been using 'to' in select case statements in VB etc. so I thought it will work. I will go by 'If Else' since 'Case 0.0,1.0,2.0' throws up missing parameter error (I have to see if it is unrelated to Case statement)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…