1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| 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 Declare Function GetUserDefaultLCID Lib "kernel32" () As Long
Public Const LOCALE_IDATE = &H21 'format de date courte : 0 = M-J-A, 1 = J-M-A, 2 = A-M-J
Public Const LOCALE_ILDATE = &H22 'format de date longue
Public Const LOCALE_SCOUNTRY = &H6 'pays en toutes lettres
Public Const LOCALE_SNATIVELANGNAME = &H4 'langue, en toutes lettres
Public Const LOCALE_STHOUSAND = &HF 'séparateur des milliers
Public Const LOCALE_SDECIMAL = &HE 'séparateur décimal
Public SeparateurDecimal As String
'Au démarrage du programme, ajouter l'appel suivant
' SeparateurDecimal = ParametreRegional(LOCALE_SDECIMAL)
Public Function ParametreRegional(parametre As Long) As String
Dim lngResultat As Long
Dim buffer As String
Dim pos As Integer
Dim locale As Long 'récupère l'identifiant de l'information locale de type utilisateur
locale = GetUserDefaultLCID() 'renvoie le nombre de caractères nécessaire pour recevoir la valeur du paramètre demandé
lngResultat = GetLocaleInfo(locale, parametre, buffer, 0)
buffer = String(lngResultat, 0)
GetLocaleInfo locale, parametre, buffer, lngResultat
pos = InStr(buffer, Chr(0))
If pos > 0 Then ParametreRegional = Left(buffer, pos - 1)
End Function |
Partager