JTmartins Active Member Licensed User Longtime User Mar 14, 2014 #1 I was trying to do a fancy thing. Not important but helpfull and came across a problem. I have a text field where all input is always in the format XX-XX-XX So I tryed this in order to add the "-" automaticaly Code: Copy Sub edtMatricula_TextChanged (Old As String, New As String) If edtMatricula.Text.Length=2 OR edtMatricula.Text.Length=5 Then edtMatricula.Text=edtMatricula.Text&"-" End If End Sub It does work partially. The problem is that after the "-" is inserted by the routine the cursor reverts to the begining of the field and the user has to move the cursor to continue typing in the proper place. I tryed some variations of the above...but always the same result. Any ideas of how to implement this ?
I was trying to do a fancy thing. Not important but helpfull and came across a problem. I have a text field where all input is always in the format XX-XX-XX So I tryed this in order to add the "-" automaticaly Code: Copy Sub edtMatricula_TextChanged (Old As String, New As String) If edtMatricula.Text.Length=2 OR edtMatricula.Text.Length=5 Then edtMatricula.Text=edtMatricula.Text&"-" End If End Sub It does work partially. The problem is that after the "-" is inserted by the routine the cursor reverts to the begining of the field and the user has to move the cursor to continue typing in the proper place. I tryed some variations of the above...but always the same result. Any ideas of how to implement this ?
Erel B4X founder Staff member Licensed User Longtime User Mar 14, 2014 #2 Add this line: Code: Copy edtMatricula.SetSelection(edtMatricula.Text.Length, edtMatricula.Text.Length) Upvote 0
Add this line: Code: Copy edtMatricula.SetSelection(edtMatricula.Text.Length, edtMatricula.Text.Length)
JTmartins Active Member Licensed User Longtime User Mar 14, 2014 #3 Ah ah...perfect as usual Erel. If there was a Nobel prize for support, you would get it in a blink of an eye. Upvote 0
Ah ah...perfect as usual Erel. If there was a Nobel prize for support, you would get it in a blink of an eye.