chris1028 Posted October 27, 2009 Posted October 27, 2009 Hi, Here's a short command-line exchange: >? format(10000/3, "#\,##0.00") "3,333.33" >? format(10000/3, "#\,##0\.00") ",33.33" eh? What happened when I escaped the dot with \. ??? Chris VS2008/VB.net Quote
chris1028 Posted October 27, 2009 Author Posted October 27, 2009 Why? I'm trying to globalize MS reportviewer ...the stupid thing ignores regionalsettings (so you get US dates (mm/dd/yyyy) and US numbers (1,234.56) independent of your settings) Dates are now under control! Numbers are more problematic - I need to handle user preferences including: 1'234.56 1'234,56 1,234.56 1.234,56 It is easy to format a number (10000/3) in user-preference "n", and parse out the separators - but how to force these separators into a custom formatstring? Chris Quote
Leaders snarfblam Posted October 27, 2009 Leaders Posted October 27, 2009 Can you specify a culture in the ToString and Parse methods of numeric types to parse and output (or convert) the right formatting? For example, if you need to convert to the local culture, use Decimal.TryParse (or float/double) with an invarant culture, then Decimal.ToString with the local culture? Quote [sIGPIC]e[/sIGPIC]
chris1028 Posted October 28, 2009 Author Posted October 28, 2009 Thanks for your reply. I've seen several mentions of the culture approach on the web, but this doesn't seem to be the route I'm looking for - culture is stuffed full of MS presumptions ...just because a user's setup is based on a certain culture doesn't prevent that user from having made personal modifs to regional settings. I gave up: all users will now see 1'234.56 on their reports. Chris Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.