Taken from one of my Code collection
VB Code:
Private Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal _
dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias _
"GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const ES_UPPERCASE As Long = &H8&
Private Const ES_LOWERCASE As Long = &H10&
Private Const ES_NUMBER As Long = &H2000
Dim DefStyle&
Private Sub Form_Load()
DefStyle = GetWindowLong(txtEdit.hwnd, GWL_STYLE)
SetTextBoxType txtEdit, ES_NUMBER
End Sub
Private Sub SetTextBoxType(Txt As TextBox, tp As Long)
Call SetWindowLong(Txt.hwnd, GWL_STYLE, DefStyle Or tp)
End Sub