Android Question Fix string length

AHilberink

Active Member
Licensed User
Longtime User
Hi,

How do I use:
Dim Text As String * 6

I want to use EditText with fixed number of characters. Is this possible or do I have to make a check myself?

Best regards,
André
 

mangojack

Well-Known Member
Licensed User
Longtime User
there is no property to set maximum characters in EditText .. you will have to manage input yourself.
B4X:
Sub EditText1_TextChanged (Old As String, New As String)
  If New > 6 Then EditText1.Text = Old
End Sub
 
Last edited:
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
Thanks for all help. It works fine now.

But:
B4X:
If New.Length > 6 Then EditText1.Text = New.Substring(0, 6)

Had to be
B4X:
If New.Length > 6 Then EditText1.Text = New.Substring2(0, 6)

André
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
apologies .. I did copy the code from an old post by Erel..

I did not dream I would have to audit it for errors !! :D
 
Upvote 0
Top