how to write if and else statement in b4a!?

Simonxman

Member
hi guys iam working on a project, in my app project i have edittext1 and a button

i want my app to work like this :
once the user write in edittext1 the word "all" and something else for exampel "allfriends " and then click on the button some msg says "this is all"

and once just the word "all" is typed without something else it shows the msg "this isnt all" i use this code but the statement if isnt working.....thanks a lot!!


if edittext1.text = "all" & edittext1.text then
msgbox ("this is all", "this is all")

else if edittext1.text = "all" then
msgbox ("this isnt all", "this isnt all")


end if
 

klaus

Expert
Licensed User
Longtime User
You can use something like this with allmost all possibilities:
B4X:
If EditText1.Text = "all" Then
    Msgbox("Only 'all'","")
Else If EditText1.Text.SubString2(0, 3) = "all" Then
    Msgbox("Begins with 'all'","")
Else If EditText1.Text.EndsWith("all") Then
    Msgbox("Ends with 'all'","")
Else If EditText1.Text.Contains("all") Then
    Msgbox("Contains 'all'","")
Else
    Msgbox("No 'all' in the string","")
End If
Of course you can remove the tests you don't need.

Best regards.
 
Upvote 0
Top