vb.net currency display has four zeros instead of two

when i get the money field from sql server to vb.net code, i always get 1.0000 instead of 1.00. how do i convert this to 1.00 in vb.net?

TD = New HtmlTableCell

If Not SqlDR("Price") Is DBNull.Value Then
    TD.InnerHtml = SqlDR("Price")
    TD.InnerHtml = "0.00"
End If

SQLDR is my sql data reader


That is because SQL Server stores the MONEY field with 4 decimal places. To see it with 2, use the String.Format method.

String.Format("{0:c}", 10) ''result: $10.00

String.Format("{0:N2}", 10) ''result: 10.00

See these pages for more ways to format your numbers

You need to format the data when you output it:


Are you sure you aren't confusing the display of the value with the actual value?

1.0000 and 1.00 are the same value.

If you want to display only a certain number of places when converting a value to a string, you should look at the Custom Numeric Format Strings section in the MSDN documentation to figure out the format string to pass to the ToString method on the Decimal, Double, Single structures, or the static Format method on the String class.

Need Your Help

Abstract classes issue in C++ undo/redo implementation

c++ inheritance abstract-class undo-redo

I have defined an "Action" pure abstract class like this:

How can I convert Solaris Containers to something VMWare or VirtualBox can use?

solaris vmware virtualbox

I have a number of application environments based in Solaris containers. Is there some method to take those environments and port them to something usable by either VMWare Workstation or Sun Virtu...