Vb.net currency display has four zeros instead of two?

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 Standard Numeric Format Strings Custom Numeric Format Strings.

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 Standard Numeric Format Strings Custom Numeric Format Strings.

Gabriel McAdams: The number of decimal places in SQL Server has nothing to do with the number of decimal places which are displayed on output. One can display it with more or less decimal places, if they desired. What matters is the type that the MONEY type in SQL Server is translated to when brought into the .

NET space, and even then, how many decimal places the type can hold is irrelevant as one can always add or remove decimal places in the display. – casperOne Feb 26 '10 at 23:38 @Casper: I completely agree. – Gabriel McAdams Feb 26 '10 at 23:57 So why make a reference to that fact in your answer?

– casperOne Feb 27 '10 at 1:18 @Casper: The OP typed when I get the money field from sql server to vb. Net code, I always get 1.0000 instead of 1.00. The question was how to display it in the way it was expected, rather than how it was returned by SQL Server.

– Gabriel McAdams Feb 27 '10 at 5:01 Which is what your answer is lacking. SQL Server doesn't have control over display characteristics, it returns a value which is then transposed onto the . NET type system.

Display has nothing to do with it. – casperOne Feb 27 '10 at 5:22.

You need to format the data when you output it: myMoney. ToString("0.00").

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.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions