Select-Case -> Mistake that I never realized

aeric

Expert
Licensed User
Longtime User
B4XLanguage v2.4 (Page 55)

Note. Differences between:


B4XVB
Select ValueSelect Case Value
Case 1, 2, 3, 4, 8, 9, 10Case 1 To 4, 8 To 9

In VB the keyword Case is added after the Select keyword.

VB accepts Case 1 To 4 , this is not implemented in B4X.

All the while I am using Select Case TestExpression (VB-style) with no issue. Starting from today, I have to take note.
 

epiCode

Active Member
Licensed User
Given the fact that adding Case after select (which I also do) does compile without error and the syntax color shows it is fairly acceptable to IDE, I guess Documentation needs to show it as optional

 

Magma

Expert
Licensed User
Longtime User
B4X:
Dim b As Double    = 101

Select Case b  'select case... actually case or not... not make so much difference!
    Case 1
            Log("xxx")
    Case 200
            Log("zzz")
    Case Else   
    If LikeTo(b,100,120)=True Then
        Log("OK")
    Else
        Log("too bad")
    End If
End Select


Sub LikeTo(num As Double,a1 As Double, a2 As Double) As Boolean
    If num>=a1  And num<=a2 Then
        Return True
        Else
        Return False
    End If
End Sub

?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…