gjoisa Active Member Licensed User Longtime User Mar 10, 2011 #1 I had written the same issue before also . My intention is to limit the text size of a edit text , while entering the text . I had written a code , but it is not working . My code is : Sub txt1_TextChanged (Old As String, New As String) old=txt1.Text If old.Length > 2 Then new = old.SubString2(0,2) End Sub How to do this ?
I had written the same issue before also . My intention is to limit the text size of a edit text , while entering the text . I had written a code , but it is not working . My code is : Sub txt1_TextChanged (Old As String, New As String) old=txt1.Text If old.Length > 2 Then new = old.SubString2(0,2) End Sub How to do this ?
Erel B4X founder Staff member Licensed User Longtime User Mar 10, 2011 #2 Code: Sub txt1_TextChanged (Old As String, New As String) If New.Length > 2 Then txt.Text = New.SubString2(0,2) End Sub Upvote 0
Code: Sub txt1_TextChanged (Old As String, New As String) If New.Length > 2 Then txt.Text = New.SubString2(0,2) End Sub
gjoisa Active Member Licensed User Longtime User Mar 10, 2011 #3 It works . But it does not fulfill my need . When I enter a third character , focus shifts to starting point , and if I enter 4th character it is accepted . Example : I entered 13 . then 4 . Text is 13 now . Now focus shifted to starting point . Now I entered 5 . Now the text is 51 . How to avoid this ?:BangHead: Upvote 0
It works . But it does not fulfill my need . When I enter a third character , focus shifts to starting point , and if I enter 4th character it is accepted . Example : I entered 13 . then 4 . Text is 13 now . Now focus shifted to starting point . Now I entered 5 . Now the text is 51 . How to avoid this ?:BangHead:
Erel B4X founder Staff member Licensed User Longtime User Mar 10, 2011 #4 When you change txt.Text also set txt.SelectionStart to 2. Upvote 0
gjoisa Active Member Licensed User Longtime User Mar 10, 2011 #5 It works fine now . Is it possible to clear an edit text , when we click on it , which contains some text while loading the activity ? I tried txt1.text= "" in both txt1_Text changed and txt1_EnterPressed . But this is not working . Upvote 0
It works fine now . Is it possible to clear an edit text , when we click on it , which contains some text while loading the activity ? I tried txt1.text= "" in both txt1_Text changed and txt1_EnterPressed . But this is not working .
Erel B4X founder Staff member Licensed User Longtime User Mar 10, 2011 #6 You can call txt1.SelectAll when the activity is created. The whole text will be selected and then erased when the user enters another character. Upvote 0
You can call txt1.SelectAll when the activity is created. The whole text will be selected and then erased when the user enters another character.
gjoisa Active Member Licensed User Longtime User Mar 10, 2011 #7 Thank you . This is my one request . Can you please add a property in designer window to limit text length ? It will be very helpful . In my app there are more than 20 edit text controls where text lengths to be limited . We can save more code lines to do so . please .. Upvote 0
Thank you . This is my one request . Can you please add a property in designer window to limit text length ? It will be very helpful . In my app there are more than 20 edit text controls where text lengths to be limited . We can save more code lines to do so . please ..