tufanv Expert Licensed User Longtime User Mar 15, 2016 #1 Hello, I have 2 floatlabeledtextviews . Their keyboard types are : Numpad with decimal. I use: Code: Sub txttry_TextChanged (OldText As String, NewText As String) If NewText="" Then txtother.Text="" Else txtother.Text=NewText/usd End If End Sub usd value is a double. So while i am typing to txttry txtother is also changing with each change. But if i use the decimal i get : java.lang.NumberFormatException: For input string: "14," I tried to change the , to . with a new code: Code: Sub txttry_TextChanged (OldText As String, NewText As String) If NewText="" Then txtother.Text="" Else If NewText.Contains(",") Then NewText.Replace(",",".") txtother.Text=NewText/usd End If End Sub this time i get no error but decimals are not calculated (if i type 1 or 1.99 it always give the same result which it must not ) What is the correct way to fix it ? TY
Hello, I have 2 floatlabeledtextviews . Their keyboard types are : Numpad with decimal. I use: Code: Sub txttry_TextChanged (OldText As String, NewText As String) If NewText="" Then txtother.Text="" Else txtother.Text=NewText/usd End If End Sub usd value is a double. So while i am typing to txttry txtother is also changing with each change. But if i use the decimal i get : java.lang.NumberFormatException: For input string: "14," I tried to change the , to . with a new code: Code: Sub txttry_TextChanged (OldText As String, NewText As String) If NewText="" Then txtother.Text="" Else If NewText.Contains(",") Then NewText.Replace(",",".") txtother.Text=NewText/usd End If End Sub this time i get no error but decimals are not calculated (if i type 1 or 1.99 it always give the same result which it must not ) What is the correct way to fix it ? TY
Erel B4X founder Staff member Licensed User Longtime User Mar 15, 2016 #2 Change: Code: If NewText.Contains(",") Then NewText.Replace(",",".") To: Code: NewText = NewText.Replace(",",".") Upvote 0
Change: Code: If NewText.Contains(",") Then NewText.Replace(",",".") To: Code: NewText = NewText.Replace(",",".")