Android Question convert string to number


New Member
hi guys
I just got a problem . I need to convert an edittext string into a number so as to use for a calculation .
I have tried the following :
Dim i AsInt
i = EditText.Text + 1

but unfortunately it doesn't work at all !

please someone tell me how to do that . in vb we do sth like this :

but I don't know how it is done in B4A . by the way , I've searched allover the forum but nothing found !

Thanks in advance


Active Member
Licensed User
Longtime User
You can include this function is yout favorite module (utils).

public Sub Val(Txt As String) As Double
If IsNumber(Txt) Then
Return Txt
Return 0
End If
End Sub

And you can replace txt by txt.replace(",",".") or similar in evaluated code.
Upvote 0