VBA currency or percent format object

C

cwsimmons

I have created a UserForm in VBA and would like users to enter currency and
percent values and see them formated as such. I can find only the TextBox
object in the Toolbox, which does not display inputs in the desired format.
Is there an object somewhere that automatically formats user inputs as
currency or percents?
 
R

ryguy7272

It's going to be something like this:

Private Sub UserForm_Click()
If TextBox1.Text <> "" Then
TextBox1.Text = Format(CDbl(TextBox1.Text), "$#,##0.00")
End If


If TextBox1.Text <> "" Then
TextBox1.Text = Format(CVar(TextBox1.Text), "##0.00%")
End If
On Error Resume Next
End Sub

HTH,
Ryan
 
Top