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.