tsteward Well-Known Member Licensed User Longtime User May 19, 2014 #1 How can I check if a string has an even number of characters?
NJDude Expert Licensed User Longtime User May 19, 2014 #2 Use LENGTH. B4X: Dim myString As String ... myString.Length And then use the MOD operator. There, you have a clue now. Upvote 0
Use LENGTH. B4X: Dim myString As String ... myString.Length And then use the MOD operator. There, you have a clue now.
tsteward Well-Known Member Licensed User Longtime User May 19, 2014 #3 Ok I have been trying to find out how to use MOD but I don't understand it and cant find a clear resource for it on here. Upvote 0
Ok I have been trying to find out how to use MOD but I don't understand it and cant find a clear resource for it on here.
NJDude Expert Licensed User Longtime User May 19, 2014 #4 The syntax is (Number MOD Number), for example: B4X: MsgBox((10 MOD 2), "") That will return 0 which means the number 10 is even. Upvote 0
The syntax is (Number MOD Number), for example: B4X: MsgBox((10 MOD 2), "") That will return 0 which means the number 10 is even.
DonManfred Expert Licensed User Longtime User May 19, 2014 #5 B4X: If x Mod 2 == 0 Then Log("Number is even") Else Log("Number is odd") End If Upvote 0