Rokko Member Licensed User Jan 22, 2018 #1 Hello to all, I need to limit the entry of an editText field to 6 digits. I tried the code Erel posted here: https://www.b4x.com/android/forum/threads/substring2-not-working-well-on-ios-8.51212/#content Code: Copy Sub TextField1_TextChanged (OldText As String, NewText As String) CallSubDelayed(Me, "CutText") End Sub Sub CutText If TextField1.Text.Length > 6 Then TextField1.Text = TextField1.Text.SubString2(0, 6) End If End Sub It works fine in debug mode but in release versions it does not. In debug it stops after 6 digits and it's not possible to enter another one. In release you can enter 7 digits and they are shown in the text field. After entering another digit (now we have entered 8 digits) it cuts the digits in the textfield to six. But that is not the way I want it. I need the same behavoir like in debug mode. Does anybody have a clue for me what I'm doing wrong?
Hello to all, I need to limit the entry of an editText field to 6 digits. I tried the code Erel posted here: https://www.b4x.com/android/forum/threads/substring2-not-working-well-on-ios-8.51212/#content Code: Copy Sub TextField1_TextChanged (OldText As String, NewText As String) CallSubDelayed(Me, "CutText") End Sub Sub CutText If TextField1.Text.Length > 6 Then TextField1.Text = TextField1.Text.SubString2(0, 6) End If End Sub It works fine in debug mode but in release versions it does not. In debug it stops after 6 digits and it's not possible to enter another one. In release you can enter 7 digits and they are shown in the text field. After entering another digit (now we have entered 8 digits) it cuts the digits in the textfield to six. But that is not the way I want it. I need the same behavoir like in debug mode. Does anybody have a clue for me what I'm doing wrong?
Erel B4X founder Staff member Licensed User Longtime User Jan 22, 2018 #2 Try this: Code: Copy Sub TextField1_TextChanged (OldText As String, NewText As String) If NewText.Length > 6 Then Sleep(20) TextField1.Text = NewText.SubString2(0, 6) End If End Sub Upvote 0
Try this: Code: Copy Sub TextField1_TextChanged (OldText As String, NewText As String) If NewText.Length > 6 Then Sleep(20) TextField1.Text = NewText.SubString2(0, 6) End If End Sub
Rokko Member Licensed User Jan 22, 2018 #3 Thank you, Erel. My Boss is not really happy with this solution(I had it too on friday) but until we find another one it will do it. Upvote 0
Thank you, Erel. My Boss is not really happy with this solution(I had it too on friday) but until we find another one it will do it.