Les dejo esta rutinita que sirve para que un TextBox acepte solo numeros (no acepta coma, ni punto) pero lo bueno es que deja pasar los tab, delete, backspace, etc. Y me parece mas sencilla que andar viendo el valor del ASCII ingresado.
'// TextBox solo numeros //
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Const GWL_STYLE = (-16)
Const ES_NUMBER = &H2000&
Public Sub TextBoxSoloNumeros(ByRef oTextBox As TextBox, Flag As Boolean)
Dim curstyle As Long, newstyle As Long
'retrieve the window style
curstyle = GetWindowLong(oTextBox.hWnd, GWL_STYLE)
If Flag Then
curstyle = curstyle Or ES_NUMBER
Else
curstyle = curstyle And (Not ES_NUMBER)
End If
'Set the new style
newstyle = SetWindowLong(oTextBox.hWnd, GWL_STYLE, curstyle)
'refresh
oTextBox.Refresh
End Sub
'Uso:
TextBoxSoloNumeros Text1, True