Unwanted decimal point in EditText View

Toley

Active Member
Licensed User
Longtime User
Hello I need to input a number in an EditText and with a button add a number to the the current value. But each time I click my button, a decimal point is added to the editText String. How can I get a plain number without this decimal point ?

Let suppose I enter the number 100 in my EditText box then I click the button.
B4X:
Sub Button1_Click
   EditText1.Text = EditText1.Text + 10
End Sub
The result will be 100.0
 

klaus

Expert
Licensed User
Longtime User
You should use an Int variable.
B4X:
Sub Globals
    Dim Number As Int     : Number = 100
End Sub

Sub Button1_Click
    Number = Number + 10
    EditText1.Text = Number
End Sub
As you are using the EditText1.Text string as a number this one is converted by default in a Double and Doubles are displayed with the dot.

Best regards.
 
Upvote 0
Top