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
 

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