ist es möglich mit VBA auszulesen welches Zeichen ("." oder ",") als Dezimaltrennzeichen von Excel bzw. vom Betriebssystem verwendet wird?
danke
Tom
Sub ChangeSystemSeparators()
Range("A1").Formula = "1,234,567.89"
MsgBox "The system separators will now change."
' Define separators and apply.
Application.DecimalSeparator = "-"
Application.ThousandsSeparator = "-"
Application.UseSystemSeparators = False
End Sub
Option Explicit
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 GetUserDefaultLCID Lib "kernel32" () As Long
Declare Function GetCurrencyFormat Lib "kernel32" Alias "GetCurrencyFormatA" (ByVal Locale As Long, ByVal dwFlags As Long, ByVal lpValue As String, lpFormat As Any, ByVal lpCurrencyStr As String, ByVal cchCurrency As Long) As Long
Const LOCALE_SDECIMAL = &HE
Const LOCALE_STHOUSAND = &HF
Sub Tausender()
Dim lngID As Long, lngCVal As Long, msg As String
lngCVal = GetUserDefaultLCID()
msg = String(255, 0)
Call GetLocaleInfo(lngID, LOCALE_STHOUSAND, msg, 255)
msg = Left$(msg, InStr(msg, Chr(0)) - 1)
MsgBox msg
End Sub
Sub Dezimal()
Dim lngID As Long, lngCVal As Long, msg As String
lngCVal = GetUserDefaultLCID()
msg = String(255, 0)
Call GetLocaleInfo(lngID, LOCALE_SDECIMAL, msg, 255)
msg = Left$(msg, InStr(msg, Chr(0)) - 1)
MsgBox msg
End Sub
Sub Waehrung()
Dim msg As String
msg = String(255, 0)
GetCurrencyFormat ByVal 0&, 0, "1234567.89", ByVal 0&, msg, Len(msg)
msg = Left$(msg, InStr(msg, Chr$(0)) - 1)
MsgBox msg
End Sub