ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   TextBox (https://www.excelbanter.com/excel-discussion-misc-queries/84165-textbox.html)

Jimbo1

TextBox
 

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

Cheers Jim.


--
Jimbo1
------------------------------------------------------------------------
Jimbo1's Profile: http://www.excelforum.com/member.php...o&userid=30637
View this thread: http://www.excelforum.com/showthread...hreadid=534502


Dave Peterson

TextBox
 
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

Jimbo1 wrote:

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

Cheers Jim.

--
Jimbo1
------------------------------------------------------------------------
Jimbo1's Profile: http://www.excelforum.com/member.php...o&userid=30637
View this thread: http://www.excelforum.com/showthread...hreadid=534502


--

Dave Peterson

Jimbo1

TextBox
 

Ive Found that this works Well

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

Cheers


--
Jimbo1
------------------------------------------------------------------------
Jimbo1's Profile: http://www.excelforum.com/member.php...o&userid=30637
View this thread: http://www.excelforum.com/showthread...hreadid=534502



All times are GMT +1. The time now is 05:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com