I want to write VB code so that the any First letter of any Word entered in the textbox will be automatically converted to Capital. Whether there is one or more than one word in the text box, any first letter of the word should be converted to Capital Letter.

for example: If I enter 'mr dr john'
the above word should be converted to 'Mr Dr John'

9 Years
Discussion Span
Last Post by QVeen72

Use the Text Change event provided by the textbox control

Private Sub Text1_Change()

End sub

I won't write your code for you. But you should check the position of the current letter. Since the text change event is fired every time you enter a different letter or change a letter, this shouldn't be a problem.

Positions you will have to test for:
(1) If the Current Letter is the first letter

(2) if the current letter is after a space.

You could use the len() function and the mid$() function to achieve your goals.


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.