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.  
Sankar030999Asked:
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.

deightonprogCommented:
Private Sub Text2_KeyPress(KeyAscii As Integer)

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

End Sub

0

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
deightonprogCommented:
SendKeys "{CAPSLOCK}", True
0
woottondCommented:
if keyAscii >= 97 and KeyAsci <= 122 then
     KeyAscii = KeyAscii - 32
endif

This will do one letter at a time...

0
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!

jzwaenepoelCommented:
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,

Joris
0
stedan_98Commented:
this solutions easier...
use the UCASE function...
e.g.

----------------------------
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)
0
Sankar030999Author Commented:
i want to accept deighton's answer. how can i do it? deighton's is very simple and satisfies my reqirements.
thanks
0
woottondCommented:
For a cut I'll help you out... ;)
kidding

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.
0
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
Sankar
0
jzwaenepoelCommented:
jzwaenepoel changed the proposed answer to a comment
0
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.