Android Question IsNaN Java error

Discussion in 'Android Questions' started by MitchBu, May 22, 2019.

  1. MitchBu

    MitchBu Active Member Licensed User

    I need to validate that the data entered is a number before storing it.

    I found this in the forum :
    Code:
    Sub IsNan(d As Double) As Boolean
       
    Return d <> d
    End Sub
    Problem is, when I call it with this :
    Code:
    Log("isnan: " & IsNan(EtRouting.Text)) ' contains "ƽƾƿǀ"
    I get this Java error :

    Error occurred on line: 286 (Main)
    java.lang.NumberFormatException: For input string: "ƽƾƿǀ"
    at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
    at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
    at java.lang.Double.parseDouble(Double.java:539)
    at anywheresoftware.b4a.debug.RDebugUtils.numberCast(RDebugUtils.java:58)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
    at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
    at com.bujardet.checkprinter.main._initedittexts(main.java:914)
    at com.bujardet.checkprinter.main._activity_create(main.java:612)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    If IsNumber(d) Then ...
     
  3. sorex

    sorex Expert Licensed User

    what's wrong with the usual isNumber command?
     
  4. MitchBu

    MitchBu Active Member Licensed User

    Thank you Erel and sorex. I searched for "NaN" in the forum, so I did not find isNumber. Sorry about that.

    Thank you :)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice