Hi,
Welcome to MSDN Newsgroup!
The default decimal places are decided on the setting of "Regional Options"
in machine. You could set the number of decimal places manually as follows,
1. Open "Control Panel"
2. Choose "Regional and Language Options"
3. Under "Regional Options" tab, click "Customize" button
4. Set the value of "No. of digits after decimal" to yours
We also could use (string.Format("{0:0.00}", value)) to force a specified
format in program.
I hope the above information is helpful for you. If you have any questions,
please feel free to join the community and we are here to support you at
your convenience. Thanks again and Merry Christmas!
Best Regards,
Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
param@community.nospam - 22 Dec 2005 19:12 GMT
Terry, for currency my Regional Settings are set to 2 decimal places. The
problem is when I cast a Decimal type to string using dec.toString("n")...
TIA!
> Hi,
> Welcome to MSDN Newsgroup!
[quoted text clipped - 21 lines]
> Microsoft Community Support
> Get Secure! www.microsoft.com/security
"TerryFei" - 23 Dec 2005 04:15 GMT
Hi,
Thanks for your feedback!
In this scenario, I want to confirm what's the setting of "Number" tab in
"Customize Regional Options". On my side, when I set "No. of digits after
decimal" value to ours, the numbers of decimal (string.toString("n")) will
adjust to the relevant setting.
If the problem is still experienced, I hope you could send me a simplified
sample so that I could repro this problem on my side and get closer to this
issue. Thanks for your understanding!
Merry Christmas!
Best Regards,
Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
param@community.nospam - 24 Dec 2005 22:14 GMT
I checked the server and the No. of digits after decimal is 2 for me. Here
is my code:-
Dim val as Decimal = Cdec(dr("val1")) ' read from datareader
input1.value = val.toString("n")
Thanks & Have a Merry Xmas!
> Hi,
> Thanks for your feedback!
[quoted text clipped - 15 lines]
> Microsoft Community Support
> Get Secure! www.microsoft.com/security
"TerryFei" - 27 Dec 2005 06:16 GMT
Hi,
Thanks for your response!
The following code works well on my side, I suggest you could test it on
your machine.
Dim val As Decimal = 10.111111
Dim str As String
str = val.ToString("n")
MsgBox(str)
These tests will help us get closer to resolving your issue, so I
appreciate your time in performing them. Let me know the results at your
earliest convenience. If you have any questions or concerns, please let me
know. I am standing by to help you.
Merry Christmas!
Best Regards,
Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
param@community.nospam - 29 Dec 2005 17:31 GMT
That code worked for me. Why doesnt it work when I read a value from the db?
thanks!
> Hi,
> Thanks for your response!
[quoted text clipped - 18 lines]
> Microsoft Community Support
> Get Secure! www.microsoft.com/security
"TerryFei" - 30 Dec 2005 02:40 GMT
Hi,
Thanks for your feedback!
Based on my experience, this issue may be related to your detailed context.
I suggest you check the format of value in database. As a workaround, you
could try to use code (string.Format("{0:0.00}", value) ) to resolve it.
If you have any questions, please feel free to let me know. Happy New Year!
Best Regards,
Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security