I'm using a variable totA to store a value from Val(txtPackageA) * discount. The output is to be dispalyed in a msgbox. However, when I put totA within the msgbox I get an error.In vb.net How do I change a variables stored value into a currency format to be shown in a msgbox?
To convert a number (such as totA in your example), you can either use CStr() or the .ToString method of the variable.
strA = CStr(totA)
- or -
strA = totA.ToString
To format a number into a currency format, use Format().
strA = totA.ToString.Format(';{0:C}';)
- or -
strA = String.Format(';{0:C}';,CStr(totA))
{0:C} means ';as currency';, which will make 1234.56 look like $1,234.56.
No comments:
Post a Comment