Android Question Problem with numbers on a calculator

tufanv

Expert
Licensed User
Longtime User
Hello
I have a simple calculator app. I am using numberformat to show 1245.32 for example as : 1,245.32

At the same time, because i have to use . instead of , for the decimal point, I change all the commas to dots with every text change.

When i use the numberformat it gives me 1,245.32 and for example the user wants to delete the last charachter the 2 , he pushes backspace and text changes to 1.245.32 .

Or lets say he found a value of 4500 : Numberformat changes it to 4,500 and when i multiply it with 5 for example it multiplies 4.5 with 5 instead of 4500.

How can i fix this ?

TY
 

tufanv

Expert
Licensed User
Longtime User
Are you also changing the decimal point to a comma?
B4X:
Sub txttry_TextChanged (OldText As String, NewText As String)
    yazan="try"
    If NewText="" Then
    txtother.Text=""
    Else
    NewText = NewText.Replace(",",".")
    txttry.Text = NewText.Replace(",",".")
    txtother.Text=NumberFormat(NewText/doviz,0,2)
    End If
   
End Sub

I use this txttry is the one textfield in euro lets say , a rate exchange app
and txtother is the dollar. When i write 5000 euro it gives automatictly to txtother.text = 1,723.01
Now when i click oın txtother.text and delete the last digit for example textchanged event fires and it changes the txtother.text to 1.723.0 and that makes txttry.text to 5 instead of around 5000
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
You cannot use a dot as both the thousands separator and as the decimal point separator.

What is the value of this number: 1.234 ? 1234 or 1234 / 1000 ?
1.234 must mean 1234 because as i said in my app when i write one of the text box 5000 it automaticly givees the dollar value of 1,723.01 (1723 and 01 cent) because of the numberformat. when i click on the other textbox and delete the last digit it changes to 1.723.0 because i change commas to dots. Altogh the number must nbe 1723 and 0 cents the app gets it as 1 dollars and 723 cent (1.723 not 1723)
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
I dont want to use it as both I know that but the probem is , in ios keyboard we dont have a dot but a comma for the numpad so i adjusted both android and ios So i replace comma with dot with every text change. and later this makes a conflict with numberformat.
You cannot use a dot as both the thousands separator and as the decimal point separator.

What is the value of this number: 1.234 ? 1234 or 1234 / 1000 ?
 
Upvote 0
Top