Hi Dvk
Try this ....
Private Sub Text1_KeyPress (KeyAscii As Integer)
//here write the code to check the key ascii is between the ascii
value of A and Z if true (i forgot the keyascii values for A to Z..sorry
for that)
If keyascii >'A keyascii value' and keyascii <'Z keyascii value'
Then
//take the character and pass the char into a global variable
and print in another text box
char = Chr(KeyAscii) or text2.text= text2.text + Chr(KeyAscii)
end If
End Sub

* sorry i dont have vb on my system to check the code...
rgds
ravikanth

Why don't you first work with your existing code and
than try to validate on Keypress event to allow only
small letter .
which will give the first Capital , ignore the
keypress event for first letter and than start
validation for all other letters.

hi dvk
with this code ever first letter of your textbox will turn
capital..i wrote this method
for example if you have a textbox named as txtcname1 and you
typein 'payal k sharda' you will get 'Payal K Sharda'..

I have got such a routine and it takes care of names like MacDonalds,
McDonalds, O'Brien as well as double-barrelled names like Farquarson-Smythe.
This it does with code looking for the "Mac", "Mc" the single quotes and the
hyphens.

It can also correctly format Machin and Macclesfield as distinct from
MacDonald's. This it does with an Ini file of overrides on the basic rules
specified above. It is all included below,

> From: email@removed To: email@removed Date
: Sat, 20 Oct 2007 09:11:41 +0000> Subject: RE:[visualbasic-l] How get only
Capital Letters in Text put from User in Text Box> > > > there is one more
simple method one can use on keypress, This convert all text to capital> >
keyascii=Asc(UCase(Chr(KeyAscii)))

Do you need to change all text to capitals on input or can it wait until
the data entry is complete and the user has moved to another
field/buttonclick etc.

If it can wait then use the lost focus event to change all text to
uppercase

Private Sub Text1_LostFocus()
Text1.Text = UCase(Text1.Text)
End Sub

If you want it done on input I would use the change event and change all
code to uppercase (I know all but the last entry will be uppercase
already)

Private Sub Text1_Change()
Text1.Text = UCase(Text1.Text)
Text1.SelStart = Len(Text1.Text)
End Sub
The second line is required to relocate the cursor at the end of the
string as the assignment in line one resets the cursor to the start of
the text.

Copyright 1998-2015 Ziff Davis, LLC (Toolbox.com). All rights reserved. All product names are trademarks of their respective companies. Toolbox.com is not
affiliated with or endorsed by any company listed at this site.