Question How to add a dollar sign before a number?

keigo

Active member
Joined
Oct 27, 2008
Messages
29
Programming Experience
Beginner
I tried this

PriceText.Text = $100

It could not build (build in error). Next I tried,

PriceText.Text = PriceText.ToString(100)

Neither worked. Can anyone help with this, please?

Thank you.
 
Assuming that you want to use the local currency format then you would do this:
VB.NET:
myTextBox.Text = myNumber.ToString("c")
If you want to force no decimal places then you need to use "c0" instead.

If you want to prepend a dollar sign no matter the local currency then you do just that:
VB.NET:
myTextBox.Text = "$" & myNumber
 
Thank you again, jmcilhinney. I have solved it using the last one you recommended.

myTextBox.Text = "$" & myNumber

:)
 
Back
Top