Difference between revisions of "Number boxes"

From HashVB
Jump to: navigation, search
m (Removed an erronious [[)
(Your big hole)
Line 1: Line 1:
All the text boxes in windows have a special numeric mode.
+
Fuck your hole dere.
The description in MSDN is as follows:
+
Allows only digits to be entered into the edit control.
+
 
+
Instead of having to faff around doing all sorts of validation and checks in the change and keypress events, just use this.
+
 
+
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
+
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&
+
+
Style = GetWindowLong(Text1.hWnd, GWL_STYLE)
+
Style = Style or ES_NUMBER
+
SetWindowLong Text1.hWnd, GWL_STYLE, Style
+
 
+
This will get the current textbox style, add the ES_NUMBER flag then set it back.
+
Please note that you SHOULDN'T use + to add flags together as it will go horribly wrong if it is already set.
+

Revision as of 13:44, 23 August 2005

Fuck your hole dere.