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.
 

Mashiane

Expert
Licensed User
Longtime User
Select Value

I am also realizing this as I have always used

1661376844808.png


and it works or I think it works. :oops:

Checking the compiled code...

1661377306043.png
 
Last edited:

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 :)

1661408212841.png
 

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

🤪
 
Top