Public 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 Public Const LOCALE_USER_DEFAULT = &H400 Public Const LOCALE_IDATE = &H21' short date format ordering Public Const LOCALE_SLANGUAGE = &H2 ' localized name of language Public Const LOCALE_SCOUNTRY = &H6 ' localized name of country Public Const LOCALE_SCURRENCY = &H14' local monetary symbol Public Const LOCALE_ILDATE = &H22' Long date format ordering Sub GetTheLocaleInfo() Dim strBuffer As String * 100 Dim lngReturn As Long Dim strResult As String Dim msg As String lngReturn = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IDATE, _ strBuffer, 99) strResult = LPSTRToVBString(strBuffer) Select Case strResult Case "0": msg = "mm/dd/yy" Case "1": msg = "dd/mm/yy" Case "2": msg = "yy/mm/dd" Case Else: msg = "#Error#" End Select Debug.Print "You are using the " & msg & " short Date format" lngReturn = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILDATE, _ strBuffer, 99) strResult = LPSTRToVBString(strBuffer) Select Case strResult Case "0": msg = "mm/dd/yyyy" Case "1": msg = "dd/mm/yyyy" Case "2": msg = "yyyy/mm/dd" Case Else: msg = "#Error#" End Select Debug.Print "You are using the " & msg & " Long Date format" lngReturn = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLANGUAGE, _ strBuffer, 99) strResult = LPSTRToVBString(strBuffer) Debug.Print "You are using " & strResult & " language" lngReturn = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SCOUNTRY, _ strBuffer, 99) strResult = LPSTRToVBString(strBuffer) Debug.Print "You live in " & strResult & "!" lngReturn = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SCURRENCY, _ strBuffer, 99) strResult = LPSTRToVBString(strBuffer) Debug.Print "You use " & strResult & " as your currency!" End Sub Public Function LPSTRToVBString(ByVal s As String) As String Dim nullpos As Integer nullpos = InStr(s, Chr(0)) If nullpos > 0 Then LPSTRToVBString = Left(s, nullpos - 1) Else LPSTRToVBString = "" End If End Function |