Android Question how to convert string to long (integer)

emexes

Expert
Licensed User
i/ never hurts to check first that the string is actually a number, eg:
B4X:
If IsNumber(SomeString) Then
    Dim Number As Long = SomeString
Else
    Log("Number? That's not a number...")
    Dim Number As Long = 999999999999999999    'that's a number ;-)
End If
or:
B4X:
Try
    Dim Number As Long = SomeString
Catch
    Log("Nice try, no cigar")
End Try
ii/ is the string readable text, or is it a packet of data of raw bytes ie in binary format?

edit: sadly, the hyperlink on the that's a number comment got lost in the code block.
 
Top