extrapolate number from edittext contains text and numbers

fifiddu70

Well-Known Member
Licensed User
Longtime User
I have an EditText with the text and a euro amount, I need to extrapolate the amount and display it on another EditText, via a button, how do I?

B4X:
Sub btneuro_Click
   ?????????? help
End Sub
 

fifiddu70

Well-Known Member
Licensed User
Longtime User
are in serious trouble, I can not figure out how to run my application, I have a textbox ( textboxdescription.text )with the following text: burger € 2.00
I want to take this textbox only the cost and display it in another textbox
(textboxeuro.text )but I have not figured out how to deal with Regex.Split
can someone give me an example?
I tried in this way but I can not get it to work
B4X:
Sub btneuro_Click
   if textboxdescription.text.contains("€") then
textboxeuro.text = textboxdescription.text.endswith("€")
end if
End Sub
not work, 
help
I realize that is not the exact code to extrapolate the cost and display it in textbox.euro
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
This code will do it:
B4X:
Sub btneuro_Click
    Dim i As Int
    i = textboxdescription.Text.IndexOf("€")
    If i >= 0 Then
        textboxeuro.Text = textboxdescription.Text.SubString2(i + 2, textboxdescription.Text.Length)
    End If
End Sub
The code assumes that there is always a blanc character between € and the cost.
The code checks if there is a € character and
if yes extracts the end of textboxdescription.Text beginning two characters after €.

Best regards.
 
Upvote 0

fifiddu70

Well-Known Member
Licensed User
Longtime User
thanks klaus, your example works fine, now I've got another request, but do it in a new post.
 
Upvote 0
Top