devxlogo

ForceTextBoxCase – Set a textbox’s upper/lowercase style

ForceTextBoxCase – Set a textbox’s upper/lowercase style

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _    (ByVal hWnd As Long, ByVal nIndex As Long) As LongPrivate Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _    (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long' Change the style of a textbox so that it automatically converts' typed characters to uppercase or lowercaseSub ForceTextBoxCase(TextBox As TextBox, Optional ConvertCase As Integer)    Dim style As Long    Const GWL_STYLE = (-16)    Const ES_UPPERCASE = &H8&    Const ES_LOWERCASE = &H10&        ' get current style    style = GetWindowLong(TextBox.hWnd, GWL_STYLE)        Select Case ConvertCase        Case 0            ' restore default style            style = style And Not (ES_UPPERCASE Or ES_LOWERCASE)        Case 1            ' convert to uppercase            style = style Or ES_UPPERCASE        Case 2            ' convert to lowecase            style = style Or ES_LOWERCASE    End Select    ' enforce new style    SetWindowLong TextBox.hWnd, GWL_STYLE, styleEnd Sub

See also  How to Avoid Money Transfer Scams  
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist