tags:

views:

37

answers:

2

In a VB6 application I have to build a file which contains a decimal number which must always be written in US format:

1,499.99

But the Format function takes the system settings into account and on a German system this result would be produced: (Using the format string #,##0.00)

1.499,99

Can I force the Format function to use different settings?

+1  A: 

try using SetThreadLocale before FormatMessage

http://msdn.microsoft.com/en-us/library/dd374051(VS.85).aspx

steelbytes
This is not working. What is `FormatMessage`?
wqw
sorry, I misread the Q, I thought the user was using FormatMessage. still, if format is really getting the system local info at time of execute, then SetThreadLocale should work. maybe VB6 is querying the locale info at app start up, and therefore SetThreadLocale may not help.
steelbytes
Actually it's OLE dlls that are caching these values from `GetLocaleInfo`
wqw
+1  A: 

Str() will always use dot as decimal delimiter, however it won't use any digit separator. You would get " 1499.99" not "1,499.99". How's that for you?

As far as I know there is no way to force the VB6 Format() function to ignore system settings.

MarkJ
It's doable by hooking `GetLocaleInfo` which is ugly. That's why I'm not proposing it as a solution to the question.
wqw