Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleMake a TextBox convert text into UPPER CASE or lower case
KeywordsTextBox, upper case, lower case, uppercase, lowercase
CategoriesControls
 
Use GetWindowLong to read the TextBox's GWL_STYLE. Use the Or operator to add on the ES_UPPERCASE or ES_LOWERCASE extended style using SetWindowLong.

Note that this method automatically converts all text without additional code in the event handlers. It also converts text pasted into the control using ^V or the context menu.

 
Private Sub Form_Load()
    SetExtendedStyle Text1.hwnd, ES_UPPERCASE
    SetExtendedStyle Text2.hwnd, ES_LOWERCASE
End Sub

' Give the control the extended style.
Private Sub SetExtendedStyle(ByVal hwnd As Long, ByVal _
    ex_style As Long)
Dim style As Long

    style = GetWindowLong(hwnd, GWL_STYLE)
    style = style Or ex_style
    SetWindowLong hwnd, GWL_STYLE, style
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated