BrettM
just a pert, "ex" to come
- Local time
- Tomorrow, 07:47
- Joined
- Apr 30, 2008
- Messages
- 134
I have a text box in which I wish to restrict the characters to be typed (no spaces) and set the length to a 10.
I have placed a simple statement in the "On Key Press" to restrict the spaces "If KeyAscii = 32 Then KeyAscii = 0" and this works great.
The issue I am facing is that the underlaying control is not actually being updated at this point so it is not possible to actually check the length as it is always NUL until the Update event.
I have tried forcing the issue a little by placing the following code in the "On Key Press" event...
Field= Field & Chr(KeyAscii)
Field.SelStart = Len(Field) 'otherwise the entire field is highlighted
If Len(Field) = 10 Then
KeyAscii = 0 'otherwise 2 items appear
End If
...however while this also works well, it completely screws up any in-field corrections that use the Delete or Backspace keys.
Can anyone offer a simple solution here?
Regards Brett
I have placed a simple statement in the "On Key Press" to restrict the spaces "If KeyAscii = 32 Then KeyAscii = 0" and this works great.
The issue I am facing is that the underlaying control is not actually being updated at this point so it is not possible to actually check the length as it is always NUL until the Update event.
I have tried forcing the issue a little by placing the following code in the "On Key Press" event...
Field= Field & Chr(KeyAscii)
Field.SelStart = Len(Field) 'otherwise the entire field is highlighted
If Len(Field) = 10 Then
KeyAscii = 0 'otherwise 2 items appear
End If
...however while this also works well, it completely screws up any in-field corrections that use the Delete or Backspace keys.
Can anyone offer a simple solution here?
Regards Brett