Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format a textbox 1

Status
Not open for further replies.

max1565

Technical User
Dec 16, 2002
57
0
0
US
could some one please tell me how to format the contents of a textbox to be currency $0.00

Thanks
 
i would simply append the "$" in front of the value before putting it in the text box. Than if you want to do math with it (having the $1.50 for instance) you can than use the CCur() command

textbox1.text="$"&textbox1.text
value = CCur(textbox1.text)


why would you need to do this though?
 
Hi max,

I assume you are talking about a textbox on a Userform?
If yes, you can code some lines in the OnExit event of the textbox:

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)

If IsNumeric(TextBox1) Then 'be sure a number is filled out
TextBox1 = Format(TextBox1, "$#,##0.00")
Else
MsgBox "Please enter a number" 'some message
End If

End Sub

Be aware that the regional settings of your computer influence the output.

Hope this helps.

Regards,
Unica
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top