VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Use SetWindowLong API call to make a text box only accept numeric input (0-9)

by Anonymous (267 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Wed 1st December 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Use SetWindowLong API call to make a text box only accept numeric input (0-9)

API Declarations


Private Const ES_NUMBER = &H2000

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


Rate Use SetWindowLong API call to make a text box only accept numeric input (0-9)



Dim lngHwnd As Long
Dim lngReturn As Long

lngHwnd = GetWindowLong(Text1.hwnd, GWL_STYLE)
lngReturn = SetWindowLong(Text1.hwnd, GWL_STYLE, lngHwnd Or ES_NUMBER)

Download this snippet    Add to My Saved Code

Use SetWindowLong API call to make a text box only accept numeric input (0-9) Comments

No comments have been posted about Use SetWindowLong API call to make a text box only accept numeric input (0-9). Why not be the first to post a comment about Use SetWindowLong API call to make a text box only accept numeric input (0-9).

Post your comment

Subject:
Message:
0/1000 characters