Results 1 to 7 of 7

Thread: SetThreadLocale Not Working

  1. #1

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Question SetThreadLocale Not Working

    I'm trying to change the ThreadLocaleID to (force) the exe to run on English UK (2057) Regional Settings, but SetThreadLocale (2057) has no effect?


    I simply need to make sure that Decimal points are returned as "." instead of ",".
    I've ready many threads / posts without much result other than manually changing the Decimal.

    Code:
    Ret = GetLocaleInfo(LCID, LOCALE_SDECIMAL, Data, DataLen)
    Yes, this works, but this does a global system change rather than a temporary change for the app.
    I also haven't found a way to simply change the whole Region>FORMAT to English UK somehow?

    Any ideas...
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  2. #2
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: SetThreadLocale Not Working


  3. #3

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Re: SetThreadLocale Not Working

    Hi dilettante,

    As much as that thread has a solution, it's rather a function than I'll need to pass for every call, rather than a Global solution.
    If I was designing from scratch, then yes, I'd be using that method, but as this is an existing BIG project, it's a no go zone to try and find every single call to fix.
    Hence why simply changing the Regional Format is a single global solution that I'm after.
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  4. #4
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,229

    Re: SetThreadLocale Not Working

    I've tried this in the past, and I've never gotten it to work or seen a solution that works.

  5. #5
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: SetThreadLocale Not Working

    Well as far as I can tell CStr(), Format$(), CDbl(), CSng(), CDec(), and CCur() always use the user's current locale. They ignore the thread's locale.

    See VarFormat function for example, which underlies Format$():

    Remarks

    This function uses the user's default locale while calling VarTokenizeFormatString and VarFormatFromTokens.
    For that matter using UK English doesn't make a lot of sense. It has a few quaint quirks. You probably want LCID_INVARIANT = 127 instead. That is the one you use for universal number formatting and parsing.

    As a quick and dirty alternative you might consider using Str$() and Val(). These are obsolete and slow and sloppy but they always use LCID_INVARIANT formatting.

  6. #6
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,129

    Re: SetThreadLocale Not Working

    Hi ,

    may sound funny but use Val that uses . instead of ,
    nomatter which Regional Settings

    regards
    Chris
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  7. #7
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: SetThreadLocale Not Working

    Not funny at all.

    The old functions from old Basic use the Invariant Locale formatting because they use U.S. English formatting which is the same thing, i.e. Earth Standard.

    Just as UTC time is the same as GMT time. Accidents of history.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width