Capitalize input

N

Nalla

Is it possable to capitalize the first letter of an users input as it is
entered into text box that is on a combo box, by useing code
thanks in advance
 
N

Nalla

Nalla said:
Is it possable to capitalize the first letter of an users input as it is
entered into text box that is on a combo box, by useing code
thanks in advance


SoOORY Mean NOT Userform not combobox
 
N

Nigel

There are no proper case commands in Excel (unlike Word). But you could
convert the value using the following construct

x = UCase(Mid(x, 1, 1)) & Mid(x, 2)

where x is the string to act upon.

To apply this to a textbox, use the change event

Private Sub TextBox1_Change()
TextBox1.Value = UCase(Mid(TextBox1.Value, 1, 1)) & Mid(TextBox1.Value, 2)
End Sub
 
G

Guest

If you mean captialize first letter of input into text box on userform then
try:

Private Sub TextBox1_Change()
With TextBox1
If Len(.Text) = 1 Then .Text = UCase(.Text)
End With
End Sub

Regards,
Greg
 
N

Nalla

Thanks Greg this work beutifully . but one more question how would i
generate the same outcome in each of several text boxes on the same
form..... would a Public Sub achieve this ?
 
B

Bob Phillips

Private Sub TextBox1_Change()
Upshift TextBox1
End Sub

Private Sub TextBox2_Change()
Upshift TextBox2
End Sub

'etc.

Private Sub Upshift(ByRef TB As MSForms.TextBox)
With TB
If Len(.Text) = 1 Then .Text = UCase(.Text)
End With
End Sub
 
D

Dick Kusleika

Nalla said:
Is it possable to capitalize the first letter of an users input as it
is entered into text box that is on a combo box, by useing code
thanks in advance

Another way is to change the text after the user is done typing, like

Private Sub TextBox1_AfterUpdate()

Me.TextBox1.Text = StrConv(Me.TextBox1.Text, vbProperCase)

End Sub

This will change the text to proper case, rather than just capitalizing the
first letter. You may prefer this method if you want to prevent the user
from typing in all caps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top