Newby textbox format question

  • Thread starter Thread starter Fred Nelson
  • Start date Start date
F

Fred Nelson

Hi:

I'm very new to vb.net and I apologize if this question should have been
found in the documentation however I don't understand the documentation.

I have a textbox on a vb.net web form that I need to load with a price - for
example $1.23

The code:

tbxPrice.text = prodprice.tostring

produces an entry of 1.2300 in the textbox

Is there a simple way for format this to display and only allow two
decimals - $1.23? I have looked at the format documentation and it doesn't
make sense.

Your help is greatly appreciated!

Fred
 
To allow two decimales

myTextBox.Text = String.format("{0:F2}", myValue)

to do it with a currency

myTextBox.Text = String.format("{0:c}", myValue)
 
CJ:

Now I get it - thank you very much!

Fred

CJ Taylor said:
To allow two decimales

myTextBox.Text = String.format("{0:F2}", myValue)

to do it with a currency

myTextBox.Text = String.format("{0:c}", myValue)
 
Back
Top