Option Explicit On
'Déclaration des fonctions API
Private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Integer, ByVal LCTYPE As Integer, ByVal lpLCData As String, ByVal cchData As Integer) As Integer
Private Declare Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (ByVal Locale As Integer, ByVal LCTYPE As Integer, ByVal lpLCData As String) As Integer
Private Declare Function GetUserDefaultLCID Lib "kernel32" () As Integer
'Déclaration de la constante séparateur décimal
Private Const LOCALE_SDECIMAL = &HE
Public Property DecimalSeparator() As String
Get
Dim nLength As Integer
Dim nLocale As Integer
nLocale = GetUserDefaultLCID()
nLength = GetLocaleInfo(nLocale, LOCALE_SDECIMAL, vbNullString, 0) - 1
DecimalSeparator = Space$(nLength)
GetLocaleInfo(nLocale, LOCALE_SDECIMAL, DecimalSeparator, nLength)
End Get
Set(ByVal value As String)
Dim nLocale As Integer
If value <> DecimalSeparator Then
If value = "." Or value = "," Then
nLocale = GetUserDefaultLCID()
SetLocaleInfo(nLocale, LOCALE_SDECIMAL, value)
End If
End If
End Set
End Property
'Exemple d'utilisation:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DecimalSeparator = "."
End Sub