Results 1 to 7 of 7
  1. #1
    Join Date
    May 2003
    Location
    Irish Girl in London !!
    Posts
    5

    Unhappy Unanswered: VB Setting the Locale ID - LCID

    Please help!
    I want to set the locale ID in my Visual Basic program to English -UK settings so that the date will be formatted dd/mm/yyyy regardless of what the computer settings are.
    In VB scripting there are GetLocale() and SetLocale() functions which I can't get to work in VB 6.0. Are there similar functions for VB?
    Any comments appreciated!!

  2. #2
    Join Date
    Feb 2003
    Location
    Montreal, Canada
    Posts
    117

    Re: VB Setting the Locale ID - LCID

    Originally posted by corla
    Please help!
    I want to set the locale ID in my Visual Basic program to English -UK settings so that the date will be formatted dd/mm/yyyy regardless of what the computer settings are.
    In VB scripting there are GetLocale() and SetLocale() functions which I can't get to work in VB 6.0. Are there similar functions for VB?
    Any comments appreciated!!
    I do not know about the existance of GetLocale() and SetLocale() in VB but you can always use FORMAT:

    FORMAT (Now, "dd/mm/yyyy")
    Steve

  3. #3
    Join Date
    May 2003
    Location
    Irish Girl in London !!
    Posts
    5

    Unhappy Re: VB Setting the Locale ID - LCID

    Hi Steve,

    Thanks for that but I couldn't get it to work for me. Am I using it correctly?

    Dim dCalldate as Date
    dCalldate = Format(date_dtp.Value, "dd/mm/yyyy")
    (where date_dtp is a DT Picker component on my form)

    It's a bit strange...it will format the date e.g. 08/05/2003 as mm/dd/yyyy
    but if I put in the date 13/05/2003 then it will format it as dd/mm/yyyy

    Thanks,
    Córla.

  4. #4
    Join Date
    Feb 2003
    Location
    Montreal, Canada
    Posts
    117

    Re: VB Setting the Locale ID - LCID

    Hi Corla,

    That's happend because you declared dCalldate as DATE instead of STRING. The FORMAT function returns a string, so there is your problem. Try this:

    Dim dCalldate as String
    dCalldate = Format (CDate(date_dtp.Value), "dd/mm/yyyy")
    Debug.Print dCalldate


    Originally posted by corla
    Hi Steve,

    Thanks for that but I couldn't get it to work for me. Am I using it correctly?

    Dim dCalldate as Date
    dCalldate = Format(date_dtp.Value, "dd/mm/yyyy")
    (where date_dtp is a DT Picker component on my form)

    It's a bit strange...it will format the date e.g. 08/05/2003 as mm/dd/yyyy
    but if I put in the date 13/05/2003 then it will format it as dd/mm/yyyy

    Thanks,
    Córla.
    Steve

  5. #5
    Join Date
    May 2003
    Location
    Irish Girl in London !!
    Posts
    5

    Wink Re: VB Setting the Locale ID - LCID

    Disco!!
    You are a star - tanx a million !!

    Córla

  6. #6
    Join Date
    Dec 2002
    Posts
    11

    Re: VB Setting the Locale ID - LCID

    Just FYI - Get/SetLocale() works in VB scripting because the Windows API is available to VB script without declaring the functions. To use API functions in VB, you would have to declare the functions in a program module:

    Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long

    Declare Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String) As Long



    These functions are native to Windows rather than VB and work on a system level.

  7. #7
    Join Date
    Feb 2003
    Location
    Montreal, Canada
    Posts
    117

    Re: VB Setting the Locale ID - LCID

    Thanks for the tip

    Originally posted by Ixalmida
    Just FYI - Get/SetLocale() works in VB scripting because the Windows API is available to VB script without declaring the functions. To use API functions in VB, you would have to declare the functions in a program module:

    Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long

    Declare Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String) As Long



    These functions are native to Windows rather than VB and work on a system level.
    Steve

Posting Permissions

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