My app has an Edit Text object and I’m trying to limit:
1) Number of characters allowed in the Edit Text object.
2) Specific characters only will be allowed to be entered.
Below you will find the code I’m using, which has no error, but when I try to run the app and start adding characters to the Edit Text object the app crashes without showing any error.
Any advice?
Thank you all
1) Number of characters allowed in the Edit Text object.
2) Specific characters only will be allowed to be entered.
Below you will find the code I’m using, which has no error, but when I try to run the app and start adding characters to the Edit Text object the app crashes without showing any error.
Any advice?
Thank you all
B4X:
Sub EditFoldrName_TextChanged (Old As String, New As String)
Dim pline As String = EditFoldrName.Text
If pline.Length > 15 Then
EditFoldrName.Text = pline.SubString2(0,15)
EditFoldrName.SelectionStart = 15
Else
If pline.Length = 0 Then Return
Dim FinalTxt, Chrk, OkCh As String
For i = 0 To (pline.Length-1)
Chrk = pline.SubString2(i, i+1)
OkCh = "no"
If Chrk = "0" Then OkCh = "yes"
If Chrk = "1" Then OkCh = "yes"
If Chrk = "2" Then OkCh = "yes"
If Chrk = "a" Then OkCh = "yes"
If Chrk = "b" Then OkCh = "yes"
If Chrk = "c" Then OkCh = "yes"
If Chrk = "@" Then OkCh = "yes"
If Chrk = "#" Then OkCh = "yes"
If Chrk = "$" Then OkCh = "yes"
If OkCh = "yes" Then
FinalTxt = FinalTxt & Chrk
End If
Next
'---------------------------------------
EditFoldrName.Text = FinalTxt
EditFoldrName.SelectionStart = EditFoldrName.Text.Length
End If
End Sub