Does anyone know if this function just checks that all characters of the string are numbers, or does it check to see if the string can be converted to a number that B4A can handle. I mean what about this
IsNumber("432432432443243234323254325437893478932489327589327589375893257893275893275932")
Would this return true ?
Hamo
I did test it for you as Steve suggested. By the way, you need IsNumber not isNumeric. Sure enough, it does show that it is a number. Why in the world would you be testing for such a big number. What is the purpose? maybe you can educate us.
B4X:
If IsNumber("432432432443243234323254325437893478932489327589327589375893257893275893275932") Then
Msgbox("Yes, I am a big number","") 'it shows that it is a number
Else
Msgbox("No, I am not a number","")
End If
Thanks for the replies, I guess I should have tested it instead of asking here.
I have a standalone controller which sends the status of all inputs and various flags as
zeros and ones over RS232. This controller also echoes everything it receives from the
Android tablet and sometimes the sent messages include garbage.
To filter out any garbage and validate the received string, I simply check that the long string
received is all numbers.
Sub isnumeric(input As String) As Boolean
Dim MatchInput As Matcher = Regex.Matcher("^[0-9]*$", input)
If MatchInput.Find = False Then
Return False
Else
Return True
End If
End Sub
Private Sub IsNumeric(var As Object) As Boolean
Return ((var Is Int) OR (var Is Double) OR (var Is Long) OR (var Is Short) OR (var Is Float) OR (var Is Double) OR (var Is Byte))
End Sub
I would ask you to inform me if it is not enough or if there is a B4A function I do not know.