Proper cased textbox input

Posted On 2018-02-26 by RenatoGesulga
Tags: VB6 String Handling 
Views: 71

This function will automatically adjust the contents of a textbox to proper case, as input is being entered.

It's not really an "in-depth" piece of code. Rather, it is just a simple something to help out beginners.

First, a function must be defined, which can be called from anywhere. Place the following code in a module.

Private Function Proper_Case(Text As TextBox)
    Text.Text = StrConv(Text.Text, vbProperCase)
    Text.SelStart = Len(Text.Text) ' get rid of the annoying input at the end of the set length
    Proper_Case = Text
End Function

Now, in the keypress event for a textbox you want to work with, place the following:

Private Sub Text1_KeyPress(KeyAscii As Integer)

    Proper_Case Text1

End Sub

Simple and to the point, this will ensure that your text inputs are "magically" proper-cased.

About the Author

has posted a total of 1 articles.

Comments On This Post

No comments on this post yet!

Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.

Your IP address is:

Before you can post, you need to prove you are human. If you log in, this test goes away.

Code Links