dcsimg
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB4/32,VB5,VB6
Expertise: Intermediate
Jun 19, 1999

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


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 Long
Private 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 lowercase

Sub 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, style
End Sub

Marco Losavio
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date