I want to calculate sum of two float numbers

kmap

Member
Licensed User
Longtime User
I want to calculate sum of two float numbers

I made 3 boxes and one button

It works for integer when i enter a float in text box it shows error

"number format exception" at run time

here is code
B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
 
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.

   Dim a,b,c As EditText
End Sub
Sub sum_click
Dim u,v,x As Float
a.InputType=a.INPUT_TYPE_DECIMAL_NUMBERS

u=a.text
v=b.Text
x=u+v
c.Text =x

End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("bb")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 

Mahares

Expert
Licensed User
Longtime User
Here is attached a working project. just unzip it and test it. It has the same exact views and layout as yours. It is working now.
 

Attachments

  • KmapTest.zip
    6.6 KB · Views: 351
Upvote 0

Mahares

Expert
Licensed User
Longtime User
unable to enter float numbers in a and b
Did you use the new layout I included in the project? I had to change your layout file. The project I zipped you worked for me just fine. I did not have any errors.
 
Upvote 0
Top