TextChanged ???

park jae hyun

Member
Licensed User
Sub EditText1_TextChanged (Old As String, New As String)
EditText1.Text= NumberFormat(EditText1.Text,1,0)
EditText1.SelectionStart =EditText1.Text.Length
End Sub
Just wanted to display the amount I do not know.
1,000,000
Mark is doing in this ...
vb are well on ...
I am not here ...
Please help.
 

kickaha

Well-Known Member
Licensed User
I do not fully understand what you are asking, but looking at your code I wonder if you are using the wrong event.

"Sub EditText1_TextChanged" is called every time there is a change in EditText1, so every time you enter a digit it will be called.

I think you may have meant to use the EnterPressed event. This runs when the user presses on the enter key or action key (Done or Next).
 

park jae hyun

Member
Licensed User
help

When you enter the amount.
Genetically programmed to automatically number are you doing out there is a comma.
Example
1,000,000
 

kickaha

Well-Known Member
Licensed User
So you want the number without the "," separator?

For this use NumberFormat2

B4X:
EditText1.Text= NumberFormat2(EditText1.Text,1,0,0,False)
 

park jae hyun

Member
Licensed User
help

Sub EditText1_TextChanged (Old As String, New As String)
EditText1.Text= NumberFormat(EditText1.Text,1,0)
--------------
EditText1.SelectionStart =EditText1.Text.Length
End Sub
EditText2.Text = NumberFormat (EditText1.Text, 1,0)
--------------
EditText2.text => automatically as you enter here for 1,000 will be marked this way.

But ...
EditText1.text => This error will leave
--------------
 
Last edited:

kickaha

Well-Known Member
Licensed User
I would help, but the language barrier is stopping me from understanding the problem :sign0013:
 

kickaha

Well-Known Member
Licensed User
I still think that changing EditText1.Text in the EditText1_TextChanged sub is leading to an infinite loop, which is why I suggested using the EditText1_EnterPressed sub.
 

park jae hyun

Member
Licensed User
help

Good way to teach us.
But ...
I want real change.
I would like to change the moment you enter.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Speak English and I'm sorry.. ^ ^
 

kickaha

Well-Known Member
Licensed User
Try this
B4X:
Sub EditText1_TextChanged (Old As String, New As String)
If NumberFormat (Old.Replace (",","") ,1,0) = New Then Return
EditText1.Text= NumberFormat(EditText1.Text.Replace (",",""),1,0)
EditText1.SelectionStart =EditText1.Text.Length 
End Sub
To go through it:

First we check if there has been any changes, if not return. This avoids the infinite loop.

Then we format the number in the box to have ","

The ".Replace (",","") " is needed because when the editbox has a number with a "," in it, it does not convert to a number so we need to remove them, convert to a number then replace them!
 

park jae hyun

Member
Licensed User
Thank you very much.

Thank you very much.
Thank you very much.
Thank you very much.
Thank you very much.
Thank you very much.
 
Top