Android Question I can figure out why i can't get the to work. I have tried several variations..

Lee Ingram

Member
Licensed User
Longtime User
B4X:
    Dim tmp As String
    Select Text
        Case Text.Contains("TOOL1")
            tmp= sf.InString (Text, ".")
            lbltool3.Color =Colors.Yellow
            lbltool3.TextColor= Colors.Black
            lbltool3.TextSize= 35
            tool3=Text.SubString2(tmp-1,tmp+4)
            lbltool3.Text= tool3

        Case Text.Contains("TOOL2")
            tmp= sf.InString (Text, ".")
            lbltool4.Color =Colors.Yellow
            lbltool4.TextColor= Colors.Black
            lbltool4.TextSize= 35
            tool4=Text.SubString2(tmp-1,tmp+4)
            lbltool4.Text= tool4

        Case Text.Contains("OP1")
                    Log(pps1)
            ppstool3.Text= pps1
          
        Case Text.Contains("OP2")
            ppstool4.Text= pps2
      
    End Select
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Please use code tags when posting code
 
Upvote 0

derez

Expert
Licensed User
Longtime User
The method "Contains" returns a boolean value, so you are telling the select to check cases of changing true and false.
You can change it to:
B4X:
Select true
case text.contains("TOOL1")
...
case text.contains("TOOL2")
...
but you have to make sure that you can't get two cases to be true for the same text value.
 
Last edited:
Upvote 0

Lee Ingram

Member
Licensed User
Longtime User
This works fine.





B4X:
If (Text.Contains("TOOL1")) Then
        tmp= sf.InString (Text, ".")
        lbltool3.Color =Colors.Yellow
        lbltool3.TextColor= Colors.Black
        lbltool3.TextSize= 35
        tool3=Text.SubString2(tmp-1,tmp+4)
        lbltool3.Text= tool3
        Log(pps1)
        ppstool3.Text= pps1
End If

If (Text.Contains("TOOL2")) Then
        tmp= sf.InString (Text, ".")
        lbltool4.Color =Colors.Yellow
        lbltool4.TextColor= Colors.Black
        lbltool4.TextSize= 35
        tool4=Text.SubString2(tmp-1,tmp+4)
        lbltool4.Text= tool4
        ppstool4.Text= pps2
    '=====================================================
End If
 
Upvote 0

Lee Ingram

Member
Licensed User
Longtime User
The method "Contains" returns a boolean value, so you are telling the select to check cases of changing true and false.
You can change it to:
Select true
case text.contains("TOOL1")
...
case text.contains("TOOL2")
...

but you have to make sure that you can't get two cases to be true for the same text value.
Thanl you
 
Upvote 0
Top