This routine will cause a textbox control to accept only numeric input. Any other input (including the '-' and '.' keys) will be ignored. Note that it is still possible to paste non-numeric data into the textbox. There have been plenty of examples of this in the last couple of days - in the comments section of one of these someone suggested using the API. So, for anyone that is interested, this is one way of doing it...
I've put this in the intermediate category only because it uses API functions - otherwise it's straightforward code. I've only tested this in VB6.0 on Win2k, but it should work on any Windows platform from Win95 up.
API DeclarationsPrivate 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
Private Const ES_NUMBER = &H2000
Private Const GWL_STYLE = -16