UCase in textbox, help

  • Thread starter Thread starter CAA
  • Start date Start date
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
 
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
 
Thanks for the help. I'm fairly new to VBA and i couldn't figure it
out.
Simple when you know how.
thanks again.
 
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?
 
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.
 
Sorry for missing the library thing in your original post. In the VBEditor, go Tools >
References and uncheck everything "missing".
 
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
 
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
 
Back
Top