UCase in textbox, help

C

CAA

I don't know what is wrong here.
I get a can't find project or library error.
Any suggestions peeps?

Private Sub TextBox1_AfterUpdate()
Dim st As String
st = TextBox1.Value
UCase (st)
TextBox1.Value = st
End Sub

Thanks for looking
CAA
 
H

Harald Staff

Hi Caa

This
UCase (st)
is not a command, it's a value. So it does nothing. Try simply

TextBox1.Text = Ucase(TextBox1.Text)

Or if you want to do this on entry, which sometimes is a good idea:

Private Sub TextBox1_KeyPress(ByVal _
KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case 97 To 255
KeyAscii = Asc(UCase$(Chr$(KeyAscii)))
Case Else
End Select
End Sub
 
K

KM

Hi,
Thats because your code is wrong, use

TextBox1.Value = Ucase(TextBox1.Value)

regards
KM
 
C

CAA

Thanks for the help. I'm fairly new to VBA and i couldn't figure it
out.
Simple when you know how.
thanks again.
 
C

CAA

Oh dear,
I'm still getting the error, I've tried both options.
What i'm trying to do is make sure the information is being transfered
from a textbox on a form to a cell and in uppercase.

Is it possible to do it on the fly? or something that will turn on caps
lock?
 
C

CAA

Yes,
I tried the keypress code and got the same error at the
Asc(UCase$(Chr$(KeyAscii))) line,
at the Chr$ part. can't find object or library.
 
H

Harald Staff

Sorry for missing the library thing in your original post. In the VBEditor, go Tools >
References and uncheck everything "missing".
 
C

CAA

No joy i'm affraid.
There are lots of references i could add, however there is about
visual basic for applications references which when selected give
name conflict with current module.
Is there a reference in particular that i need?

CA
 
T

Tom Ogilvy

You shouldn't be adding references, you should be unchecking the one that
says MISSING.
 
C

CAA

Sorry,I totaly missed the mark there

Thanks alot, that worked brilliantly, all is good.

I can't imagine how on earth that helped but it did

CAA
 
Top