En poursuivant votre navigation sur ce site, vous acceptez l'utilisation de cookies pour vous proposer des contenus et services adaptés. Mentions légales.

Recherche

Recherche

Les mémos

Je débute...

Visites

 1251946 visiteurs

 1 visiteur en ligne

Nous contacter

Contact

Paramètres régionaux

Lecture des Paramètres Régionaux

Commencez par faire les déclarations nécessaires dans un module standard

'/
'/ A placer dans la partie déclarative
'/
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

Private Declare Function GetUserDefaultLCID% Lib "kernel32" ()

' Ci-dessous les différentes constantes
Const LOCALE_SDECIMAL = &HE
Const LOCALE_SCURRENCY = &H14
Const LOCALE_SINTLSYMBOL = &H15
Const LOCALE_SCOUNTRY = &H6
Const LOCALE_SENGCOUNTRY = &H1002
Const LOCALE_SNATIVELANGNAME = &H4
Const LOCALE_SABBREVLANGNAME = &H3
Const LOCALE_SSHORTDATE = &H1F
Const LOCALE_SLONGDATE = &H20
Const LOCALE_IDEFAULTCODEPAGE = &HB

Vous complétez ensuite par les fonctions désirées :

Symbole Décimal

Function SymbolDecimal() As String
    Dim Symbol As String
    Dim iRet1 As Long
    Dim iRet2 As Long
    Dim lpLCDataVar As String
    Dim pos As Integer
    Dim Locale As Long

    Locale = GetUserDefaultLCID()
    iRet1 = GetLocaleInfo(Locale, LOCALE_SDECIMAL, lpLCDataVar, 0)
    Symbol = String$(iRet1, 0)
    iRet2 = GetLocaleInfo(Locale, LOCALE_SDECIMAL, Symbol, iRet1)
    pos = InStr(Symbol, Chr$(0))
    If pos > 0 Then
        Symbol = Left$(Symbol, pos - 1)
        SymbolDecimal = Symbol
    End If

End Function

Symbole Monétaire Régional

Public Function SymboleMonetaireRegional() As String
    Dim Symbol As String
    Dim iRet1 As Long
    Dim iRet2 As Long
    Dim lpLCDataVar As String
    Dim pos As Integer
    Dim Locale As Long

    Locale = GetUserDefaultLCID()
    iRet1 = GetLocaleInfo(Locale, LOCALE_SCURRENCY, lpLCDataVar, 0)

    Symbol = String$(iRet1, 0)
    iRet2 = GetLocaleInfo(Locale, LOCALE_SCURRENCY, Symbol, iRet1)
    pos = InStr(Symbol, Chr$(0))
    If pos > 0 Then
        Symbol = Left$(Symbol, pos - 1)
        SymboleMonetaireRegional = Symbol
    End If

End Function

Symbole Monétaire ISO

Public Function SymboleMonetaireISO() As String
    Dim Symbol As String
    Dim iRet1 As Long
    Dim iRet2 As Long
    Dim lpLCDataVar As String
    Dim pos As Integer
    Dim Locale As Long

    Locale = GetUserDefaultLCID()
    iRet1 = GetLocaleInfo(Locale, LOCALE_SINTLSYMBOL, lpLCDataVar, 0)
    Symbol = String$(iRet1, 0)
    iRet2 = GetLocaleInfo(Locale, LOCALE_SINTLSYMBOL, Symbol, iRet1)
    pos = InStr(Symbol, Chr$(0))
    If pos > 0 Then
        Symbol = Left$(Symbol, pos - 1)
        SymboleMonetaireISO = Symbol
    End If

End Function

Nom du Pays

Public Function NomDuPays() As String
    Dim Symbol As String
    Dim iRet1 As Long
    Dim iRet2 As Long
    Dim lpLCDataVar As String
    Dim pos As Integer
    Dim Locale As Long

    Locale = GetUserDefaultLCID()
    iRet1 = GetLocaleInfo(Locale, LOCALE_SCOUNTRY, lpLCDataVar, 0)
    Symbol = String$(iRet1, 0)
    iRet2 = GetLocaleInfo(Locale, LOCALE_SCOUNTRY, Symbol, iRet1)
    pos = InStr(Symbol, Chr$(0))
    If pos > 0 Then
        Symbol = Left$(Symbol, pos - 1)
        NomDuPays = Symbol
    End If

End Function

Nom du Pays en Anglais

Public Function NomDuPaysEnAnglais() As String
    Dim Symbol As String
    Dim iRet1 As Long
    Dim iRet2 As Long
    Dim lpLCDataVar As String
    Dim pos As Integer
    Dim Locale As Long

    Locale = GetUserDefaultLCID()
    iRet1 = GetLocaleInfo(Locale, LOCALE_SENGCOUNTRY, lpLCDataVar, 0)
    Symbol = String$(iRet1, 0)
    iRet2 = GetLocaleInfo(Locale, LOCALE_SENGCOUNTRY, Symbol, iRet1)
    pos = InStr(Symbol, Chr$(0))
    If pos > 0 Then
        Symbol = Left$(Symbol, pos - 1)
        NomDuPaysEnAnglais = Symbol
    End If

End Function

Langue en cours

Public Function LangueEnCours() As String
    Dim Symbol As String
    Dim iRet1 As Long
    Dim iRet2 As Long
    Dim lpLCDataVar As String
    Dim pos As Integer
    Dim Locale As Long

    Locale = GetUserDefaultLCID()
    iRet1 = GetLocaleInfo(Locale, LOCALE_SNATIVELANGNAME, lpLCDataVar, 0)

    Symbol = String$(iRet1, 0)
    iRet2 = GetLocaleInfo(Locale, LOCALE_SNATIVELANGNAME, Symbol, iRet1)
    pos = InStr(Symbol, Chr$(0))
    If pos > 0 Then
        Symbol = Left$(Symbol, pos - 1)
        LangueEnCours = Symbol
    End If

End Function

Langue Abrégée

Public Function LangueAbregee() As String
    Dim Symbol As String
    Dim iRet1 As Long
    Dim iRet2 As Long
    Dim lpLCDataVar As String
    Dim pos As Integer
    Dim Locale As Long

    Locale = GetUserDefaultLCID()
    iRet1 = GetLocaleInfo(Locale, LOCALE_SABBREVLANGNAME, lpLCDataVar, 0)

    Symbol = String$(iRet1, 0)
    iRet2 = GetLocaleInfo(Locale, LOCALE_SABBREVLANGNAME, Symbol, iRet1)
    pos = InStr(Symbol, Chr$(0))
    If pos > 0 Then
        Symbol = Left$(Symbol, pos - 1)
        LangueAbregee = Symbol
    End If

End Function

Format Date Court

Public Function FormatDateCourt() As String
    Dim Symbol As String
    Dim iRet1 As Long
    Dim iRet2 As Long
    Dim lpLCDataVar As String
    Dim pos As Integer
    Dim Locale As Long

    Locale = GetUserDefaultLCID()
    iRet1 = GetLocaleInfo(Locale, LOCALE_SSHORTDATE, lpLCDataVar, 0)
    Symbol = String$(iRet1, 0)
    iRet2 = GetLocaleInfo(Locale, LOCALE_SSHORTDATE, Symbol, iRet1)
    pos = InStr(Symbol, Chr$(0))
    If pos > 0 Then
        Symbol = Left$(Symbol, pos - 1)
        FormatDateCourt = Symbol
    End If

End Function

Format Date Long

Public Function FormatDateLong() As String
    Dim Symbol As String
    Dim iRet1 As Long
    Dim iRet2 As Long
    Dim lpLCDataVar As String
    Dim pos As Integer
    Dim Locale As Long

    Locale = GetUserDefaultLCID()
    iRet1 = GetLocaleInfo(Locale, LOCALE_SLONGDATE, lpLCDataVar, 0)
    Symbol = String$(iRet1, 0)
    iRet2 = GetLocaleInfo(Locale, LOCALE_SLONGDATE, Symbol, iRet1)
    pos = InStr(Symbol, Chr$(0))
    If pos > 0 Then
        Symbol = Left$(Symbol, pos - 1)
        FormatDateLong = Symbol
    End If

End Function

Code Page

Public Function CodePage() As String
    Dim Symbol As String
    Dim iRet1 As Long
    Dim iRet2 As Long
    Dim lpLCDataVar As String
    Dim pos As Integer
    Dim Locale As Long

    Locale = GetUserDefaultLCID()
    iRet1 = GetLocaleInfo(Locale, LOCALE_IDEFAULTCODEPAGE, lpLCDataVar, 0)
    Symbol = String$(iRet1, 0)
    iRet2 = GetLocaleInfo(Locale, LOCALE_IDEFAULTCODEPAGE, Symbol, iRet1)
    pos = InStr(Symbol, Chr$(0))
    If pos > 0 Then
        Symbol = Left$(Symbol, pos - 1)
        CodePage = Symbol
    End If

End Function


La liste des constantes paramètres régionaux

(pour créer de nouvelles fonctions sur le même modèle ...)
 

Const LOCALE_SCURRENCY = &H14       ' local monetary symbol
Const LOCALE_SINTLSYMBOL = &H15     ' intl monetary symbol
Const LOCALE_ILANGUAGE = &H1        ' language id
Const LOCALE_SLANGUAGE = &H2        ' localized name of language
Const LOCALE_SENGLANGUAGE = &H1001  ' English name of language
Const LOCALE_SABBREVLANGNAME = &H3  ' abbreviated language name
Const LOCALE_SNATIVELANGNAME = &H4  ' native name of language
Const LOCALE_ICOUNTRY = &H5         ' country code
Const LOCALE_SCOUNTRY = &H6         ' localized name of country
Const LOCALE_SENGCOUNTRY = &H1002   ' English name of country
Const LOCALE_SABBREVCTRYNAME = &H7  ' abbreviated country name
Const LOCALE_SNATIVECTRYNAME = &H8  ' native name of country
Const LOCALE_IDEFAULTLANGUAGE = &H9 ' default language id
Const LOCALE_IDEFAULTCOUNTRY = &HA  ' default country code
Const LOCALE_IDEFAULTCODEPAGE = &HB ' default code page
Const LOCALE_SMONDECIMALSEP = &H16  ' monetary decimal separator
Const LOCALE_SMONTHOUSANDSEP = &H17 ' monetary thousand separator
Const LOCALE_SMONGROUPING = &H18    ' monetary grouping
Const LOCALE_ICURRDIGITS = &H19     ' # local monetary digits
Const LOCALE_IINTLCURRDIGITS = &H1A ' # intl monetary digits
Const LOCALE_ICURRENCY = &H1B       ' positive currency mode
Const LOCALE_INEGCURR = &H1C        ' negative currency mode
Const LOCALE_SDECIMAL = &HE       ' number decimal separator
Const LOCALE_SDATE = &H1D         ' date separator
Const LOCALE_STIME = &H1E         ' time separator
Const LOCALE_SSHORTDATE = &H1F    ' short date format string
Const LOCALE_SLONGDATE = &H20     ' long date format string
Const LOCALE_STIMEFORMAT = &H1003 ' time format string
Const LOCALE_IDATE = &H21         ' short date format ordering
Const LOCALE_ILDATE = &H22        ' long date format ordering
Const LOCALE_ITIME = &H23         ' ime format specifier
Const LOCALE_ICENTURY = &H24      ' century format specifier
Const LOCALE_ITLZERO = &H25       ' leading zeros in time field
Const LOCALE_IDAYLZERO = &H26     ' leading zeros in day field
Const LOCALE_IMONLZERO = &H27     ' leading zeros in month field
Const LOCALE_S1159 = &H28         ' AM designator
Const LOCALE_S2359 = &H29         ' PM designator


Catégorie : Les mémos - Administration
Page lue 9307 fois

Vous êtes ici :   Accueil » Paramètres régionaux