Rob P Rob P - 18 days ago 7x Question

How can I set an output value to 2 decimal places in Visual Studio?

Im putting together a basic Gross Profit Calculator in Visual Studio and need the output to show as a £ value, ie to 2 decimal places.

I have tried this so far:

String.Format("{0:0.00}", TextBox3.Text = CStr(sale))

where TextBox3 is the output for the calculation. However on using this, nothing happens and the box remains empty and I can't work out why!


Your syntax is not correct, re-write your code this way:

TextBox3.Text = String.Format("{0:0.00}", sale)

The String.Format's result wasn't being assigned to anything.