A. Try the following
Private Sub Text1_KeyPress(KeyAscii As Integer)It may be more efficient to declare intDecChar on module or public level and
move the 3rd line above so that it is only performed once for every form or once
for every programme execution.
If you have several text boxes, where you want to implement this behaviour, on a form, you
should put the procedure above in the Form_KeyPress event and
set the Form's Preview property True.