TextBox

J

Jimbo1

Hi,
On a Userform, does anyone know if you can set a textbox up so tha
when characters are entered they are automatically changed to uppe
case?

Cheers Jim
 
D

Dave Peterson

One way is to check after each character is typed:

Option Explicit
Dim BlkProc As Boolean
Private Sub TextBox1_Change()
If BlkProc = True Then Exit Sub
BlkProc = True
Me.TextBox1.Value = UCase(Me.TextBox1.Value)
BlkProc = False
End Sub

Another way is to just let the user type what they want and make it uppercase
when they leave the textbox.

Option Explicit
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Me.TextBox1.Value = UCase(Me.TextBox1.Value)
End Sub

And you could just make it uppercase when your code needs it and let the textbox
display what the user typed.

Option Explicit
Private Sub CommandButton1_Click()
MsgBox UCase(Me.TextBox1.Value)
End Sub
 
J

Jimbo1

Ive Found that this works Well

Private Sub Textbox1_Change()
TextBox1.Text = UCase(TextBox1.Text)
End Sub

Cheer
 
Top