text box in uppercase

as i enter the text in a text box, i want it to be displayed in ucase. the ucase fn cannot be used bcos this has to be done as i enter every char. how can this be done. i need the code.
also how can i control capslock from within my app. is this can be done, please let me know how.  
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Private Sub Text2_KeyPress(KeyAscii As Integer)

    KeyAscii = Asc(UCase(Chr(KeyAscii)))

End Sub


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SendKeys "{CAPSLOCK}", True
if keyAscii >= 97 and KeyAsci <= 122 then
     KeyAscii = KeyAscii - 32

This will do one letter at a time...

The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Place the following code in a module:

Private Const ES_UPPERCASE = &H8&
Private Const GWL_STYLE = (-16)

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Public Function SetTextBoxUCase(txtX As TextBox) As Long
On Error Resume Next

Dim lStyle As Long

     lStyle = GetWindowLong(txtX.hWnd, GWL_STYLE)
     lStyle = lStyle Or ES_UPPERCASE
     SetTextBoxUCase = SetWindowLong(txtX.hWnd, GWL_STYLE, lStyle)

End Function

Place this code in the form_load-event:

Private Sub Form_Load()

    Call SetTextBoxUCase(Text1)
End Sub

Hope this helps,

this solutions easier...
use the UCASE function...

In General Declarations Put:

dim text$ as string

on the text1_keypress event put in this code:

text$ = text1.text
text1.text = UCASE(text$)

(assuming your textbox is named text1)

hope this helps...
(UCASE is a standard VB function so it requires no modules or extra code than what you see above)
Sankar030999Author Commented:
i want to accept deighton's answer. how can i do it? deighton's is very simple and satisfies my reqirements.
For a cut I'll help you out... ;)

Un I think there is an option accept as answer... just click on that - I've done it before but that doesn't really help does it.
Sankar030999Author Commented:
the option "accept comment as answer" was there few days ago. but i guess the site has removed those options now. it isnt there in all the q's
jzwaenepoel changed the proposed answer to a comment
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.