Android Question [SOLVED] Bug with double????

makis_best

Well-Known Member
Licensed User
Longtime User
Hi.

I have a table with 4 columns Quantity, Price, Total and add to order.
When I add quantity and Price in column total I see the result
For example if I put in quantity 100 and in price 11.4307
then I get total as 1,143.07.

After that I press the Add to order button witch read the total column
my program stop working and I get one error message saying about invalid double.

** Activity (esfiitems) Create, isFirst = true **
** Activity (esfiitems) Resume **
Error occurred on line: 969 (Table)
java.lang.NumberFormatException: Invalid double: "1,143.07"
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.initialParse(StringToReal.java:164)
at java.lang.StringToReal.parseDouble(StringToReal.java:282)
at java.lang.Double.parseDouble(Double.java:301)
at gr.iosif.droidview.esfiitems$ResumableSub_ItemTable_All_Items_CellClick.resume(esfiitems.java:2445)
at gr.iosif.droidview.esfiitems._itemtable_all_items_cellclick(esfiitems.java:1884)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
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)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1083)
at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1046)
at gr.iosif.droidview.table._cell_click(table.java:1568)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
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)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:4764)
at android.view.View$PerformClick.run(View.java:19844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5376)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)

Why that happens?
It is about decimal format?

I use Table CustomView Version 3.02 and Android 8 with B4A 9.50

Thank you
 

makis_best

Well-Known Member
Licensed User
Longtime User
The code I use to fill the cell
B4X:
ItemTable_All_Items.SetValue(5, row, NumberFormat(Quantity1 * ItemTable_All_Items.GetValue(3, row), 0, 4))
I just want to have 4 digits after decimal.
 
Last edited:
Upvote 0

advansis

Active Member
Licensed User
Longtime User
What about storing the real value used for calculation (multiplied by 10000 and rounded) in an hidden column?
 
Upvote 0
Top