Force Capitalization in all Textboxes on Form
Code:
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
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
Private Const GWL_STYLE = (-16)
Private Const WS_MINIMIZEBOX = &H20000
'edit styles used
Private Const ES_UPPERCASE As Long = &H8&
Private Const ES_LOWERCASE As Long = &H10&
Private Const ES_NUMBER As Long = &H2000
Private Sub Form_Load()
Dim lngStyle As Long
Dim ctl As Control
For Each ctl In Controls
If TypeOf ctl Is TextBox Then
lngStyle = GetWindowLong(ctl.hwnd, GWL_STYLE)
Call SetWindowLong(ctl.hwnd, GWL_STYLE, lngStyle Or ES_UPPERCASE)
End If
Next
End Sub
Re: Force Capitalization in all Textboxes on Form