Formatting Text Boxes in UserForms

K

KG

When designing text boxes for data entry, can the text
box controls on the UserForm be assigned number
formatting properties?

For example, how would I arrange for data in TextBox1 to
be in % with one decimal point, preferrably with a
trailing % sign?
 
D

Dave Peterson

You can format the value that goes in the textbox the way you want. Maybe
something like:

Option Explicit
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If IsNumeric(Me.TextBox1.Value) Then
Me.TextBox1.Value = Format(Me.TextBox1.Value / 100, "#0.0%")
End If
End Sub
 
K

KG

I'm going to give it a try. Thanks!
-----Original Message-----
You can format the value that goes in the textbox the way you want. Maybe
something like:

Option Explicit
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If IsNumeric(Me.TextBox1.Value) Then
Me.TextBox1.Value = Format(Me.TextBox1.Value / 100, "#0.0%")
End If
End Sub



--

Dave Peterson
[email protected]
.
 
Top