![]() |
'This project needs a TextBox 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 SetNumber(NumberText As TextBox, Flag As Boolean) Dim curstyle As Long, newstyle As Long 'retrieve the window style curstyle = GetWindowLong(NumberText.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(NumberText.hwnd, GWL_STYLE, curstyle) 'refresh NumberText.Refresh End Sub Private Sub Form_Load() 'KPD-Team 1999 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam@Allapi.net SetNumber Text1, True Me.Caption = "Now, try typing some letters into the textbox" End Sub |