limit text size

gjoisa

Active Member
Licensed User
Longtime User
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 ?
 

gjoisa

Active Member
Licensed User
Longtime User
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

gjoisa

Active Member
Licensed User
Longtime User
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

gjoisa

Active Member
Licensed User
Longtime User
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
Top