Hi,

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'

Recommended Answers

All 2 Replies

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.

Hank

Hi,

Just use Propercase:

Text1.Text=StrConv(Text1.Text ,vbProperCase)

Regards
Veena

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.