tufanv Expert Licensed User Longtime User Jun 21, 2016 #1 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
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
Erel B4X founder Staff member Licensed User Longtime User Jun 21, 2016 #2 Are you also changing the decimal point to a comma? Upvote 0
tufanv Expert Licensed User Longtime User Jun 21, 2016 #3 Erel said: Are you also changing the decimal point to a comma? Click to expand... No Upvote 0
tufanv Expert Licensed User Longtime User Jun 21, 2016 #4 Erel said: Are you also changing the decimal point to a comma? Click to expand... Code: Copy 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
Erel said: Are you also changing the decimal point to a comma? Click to expand... Code: Copy 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
Erel B4X founder Staff member Licensed User Longtime User Jun 21, 2016 #5 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
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 ?
tufanv Expert Licensed User Longtime User Jun 21, 2016 #6 Erel said: 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 ? Click to expand... 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
Erel said: 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 ? Click to expand... 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)
tufanv Expert Licensed User Longtime User Jun 21, 2016 #7 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. Erel said: 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 ? Click to expand... Upvote 0
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. Erel said: 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 ? Click to expand...
Erel B4X founder Staff member Licensed User Longtime User Jun 21, 2016 #8 My suggestion is to never modify the text inside the TextChanged event. It is simpler and provide better experience for the user if you modify it when the focus is lost or in the EndEdit event in B4i. Upvote 0
My suggestion is to never modify the text inside the TextChanged event. It is simpler and provide better experience for the user if you modify it when the focus is lost or in the EndEdit event in B4i.