Search Tools Links Login

Proper cased textbox input


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 this post

Posted: 2018-02-26
By: RenatoGesulga
Viewed: 352 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.