Results 1 to 6 of 6

Thread: [RESOLVED] Make everything in textbox lowercase.

  1. #1

    Thread Starter
    Addicted Member Garrett19212's Avatar
    Join Date
    Jan 2005
    Location
    US
    Posts
    220

    Resolved [RESOLVED] Make everything in textbox lowercase.

    How can I make everything in a textbox lowercase.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Make everything in textbox lowercase.

    VB Code:
    1. Text1.Text = LCase(Text1.Text)

  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Make everything in textbox lowercase.

    You can do that "as you type" and/or on LostFocus evnt:
    VB Code:
    1. Private Sub Text1_KeyPress(KeyAscii As Integer)
    2.     KeyAscii = Asc(LCase(Chr(KeyAscii)))
    3. End Sub
    4.  
    5. Private Sub Text1_LostFocus()
    6.     Text1.Text = LCase(Text1.Text)
    7. End Sub

  4. #4

    Thread Starter
    Addicted Member Garrett19212's Avatar
    Join Date
    Jan 2005
    Location
    US
    Posts
    220

    Re: Make everything in textbox lowercase.

    Thank you both.

  5. #5
    Addicted Member
    Join Date
    Jun 2005
    Posts
    192

    Re: Make everything in textbox lowercase.

    Private Sub textbox_change()
    textbox.text = LCase(textbox.text)
    End Sub

    (Yall beat me to it)

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: [RESOLVED] Make everything in textbox lowercase.

    You can also change the style of the TextBox so that it automatically changes all characters to lower case as they are typed. This will also change the characters that are pasted into the control.
    VB Code:
    1. Private Declare Function SetWindowLong _
    2.  Lib "user32.dll" Alias "SetWindowLongA" ( _
    3.  ByVal hwnd As Long, _
    4.  ByVal nIndex As Long, _
    5.  ByVal dwNewLong As Long) As Long
    6.  
    7. Private Declare Function GetWindowLong Lib "user32.dll" _
    8.  Alias "GetWindowLongA" ( _
    9.  ByVal hwnd As Long, _
    10.  ByVal nIndex As Long) As Long
    11.  
    12. Private Const GWL_STYLE As Long = -16
    13. Private Const ES_LOWERCASE As Long = &H10&
    14.  
    15. Private Sub Form_Load()
    16.     Dim nStyle As Long
    17.     nStyle = GetWindowLong(Text1.hwnd, GWL_STYLE) Or ES_LOWERCASE
    18.     Call SetWindowLong(Text1.hwnd, GWL_STYLE, nStyle)
    19. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width