Alberto Michelis Well-Known Member Licensed User Longtime User Jul 25, 2015 #1 Some times I get the image error, it allways says the problem is in my CodeModule (where I code my repetitive subs) and in NumberFormat function, but that function is not used in that module. The times it happened to me I recompile in Debug and sometimes, not allways I found the error, sometimes not. Problem is I try to reproduce the user error and it does not happened. Is there eny way to trap it and to know from what line of code it is? Thanks Attachments error.png 47.3 KB · Views: 461
Some times I get the image error, it allways says the problem is in my CodeModule (where I code my repetitive subs) and in NumberFormat function, but that function is not used in that module. The times it happened to me I recompile in Debug and sometimes, not allways I found the error, sometimes not. Problem is I try to reproduce the user error and it does not happened. Is there eny way to trap it and to know from what line of code it is? Thanks
R Roycefer Well-Known Member Licensed User Longtime User Jul 25, 2015 #2 java.lang.NumberFormatException isn't necessarily from the NumberFormat function. It's typically caused by trying to cast a String to a double. From the looks of your error message, it seems you're trying to cast an empty String to a double. Without seeing your code, it's hard to say where it happens but this kind of error is common whenever your program prompts the user for numerical input (like in an EditText) and the user inputs an empty String and then clicks OK. To stop this from throwing that NumberFormatException, you should test user input for validity before trying to use it. Try-Catch blocks are good, as is the isNumber() function. Upvote 0
java.lang.NumberFormatException isn't necessarily from the NumberFormat function. It's typically caused by trying to cast a String to a double. From the looks of your error message, it seems you're trying to cast an empty String to a double. Without seeing your code, it's hard to say where it happens but this kind of error is common whenever your program prompts the user for numerical input (like in an EditText) and the user inputs an empty String and then clicks OK. To stop this from throwing that NumberFormatException, you should test user input for validity before trying to use it. Try-Catch blocks are good, as is the isNumber() function.
Alberto Michelis Well-Known Member Licensed User Longtime User Jul 25, 2015 #3 Weird... I use a sub like Code: Copy Sub TextValue(inText As String) As Double If IsNumber(inText.Trim.Replace(",",""))=False Then Return 0 Else Return inText.trim.Replace(",","") End If End Sub Any else I can add? Upvote 0
Weird... I use a sub like Code: Copy Sub TextValue(inText As String) As Double If IsNumber(inText.Trim.Replace(",",""))=False Then Return 0 Else Return inText.trim.Replace(",","") End If End Sub Any else I can add?
R Roycefer Well-Known Member Licensed User Longtime User Jul 25, 2015 #4 Try going into Objects/src/your/package/name and opening the .java file that has that function and see what's going on on line 153. You can open .java files with a normal text editor like Notepad (though you'll probably want one that displays line numbers). Upvote 0
Try going into Objects/src/your/package/name and opening the .java file that has that function and see what's going on on line 153. You can open .java files with a normal text editor like Notepad (though you'll probably want one that displays line numbers).
NJDude Expert Licensed User Longtime User Jul 25, 2015 #5 The answer is simple, if you are returning a DOUBLE you CANNOT return an empty string. Upvote 0