jeffreyccs
New member
- Local time
- Today, 01:43
- Joined
- Nov 10, 2012
- Messages
- 29
Hi
I have a query regarding the above, I have tried using the keypress event to restrict entry to numeric values only and that functions correctly. The issue that I have is that there are a number of textboxes and like most people I will use the enter or tab keys to move between them. unfortunately the on keypress event does not work with enter or tab and triggers the error message.
I would be grateful if anyone has an alternative method that I could try.
I have a query regarding the above, I have tried using the keypress event to restrict entry to numeric values only and that functions correctly. The issue that I have is that there are a number of textboxes and like most people I will use the enter or tab keys to move between them. unfortunately the on keypress event does not work with enter or tab and triggers the error message.
Code:
Private Sub tb1l_KeyPress(KeyAscii As Integer)
If (KeyAscii > 47 And KeyAscii < 58) Or (KeyAscii = 8) Or (KeyAscii = 9) Or (KeyAscii = 10) Then
KeyAscii = KeyAscii
Else:
MsgBox "Numberic Data Only!", vbOKOnly, "Invalid Data"
KeyAscii = 0
End If
End Sub
I would be grateful if anyone has an alternative method that I could try.