Option Explicit
'By: eko cahyono (idym: eko_matrix)
Const LOCALE_SDECIMAL = &HE ' decimal separator
Const LOCALE_STHOUSAND = &HF ' thousand separator
Const LOCALE_SGROUPING = &H10 ' digit grouping
Const LOCALE_IDIGITS = &H11 ' number of fractional digits
Const LOCALE_ILZERO = &H12 ' leading zeros for decimal
Const LOCALE_SNATIVEDIGITS = &H13 ' native ascii 0-9
Const LOCALE_SCURRENCY = &H14 ' local monetary symbol
Const LOCALE_SINTLSYMBOL = &H15 ' intl monetary symbol
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_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 ' time format specifier
Const LOCALE_ICENTURY = &H24 ' century format specifier
Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long
Private Declare Function GetUserDefaultLCID Lib "kernel32" () As Long
Private 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 SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" _
(ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String) As Long
Function GetRegional(nFormat As Long, Optional SetValue As String = -1) As String
Dim vNilai As String, vLcid As Long, Ret As Long
vLcid = GetUserDefaultLCID()
vNilai = Space$(vLcid)
Ret = GetLocaleInfo(vLcid, nFormat, vNilai, Len(vNilai))
If Ret Then
If SetValue <> "-1" Then
Call SetLocaleInfo(vLcid, nFormat, CStr(SetValue))
End If
GetRegional = Left$(vNilai, Ret - 1)
End If
End Function
Private Sub Command1_Click()
'Ganti mata uang
MsgBox "Format Lama Mata Uang: " & GetRegional(LOCALE_SCURRENCY)
Call GetRegional(LOCALE_SCURRENCY, "vb")
MsgBox "Format Baru Mata Uang: " & GetRegional(LOCALE_SCURRENCY)
'Ganti mata Decimal
MsgBox "Format Decimal Lama: " & GetRegional(LOCALE_SDECIMAL)
Call GetRegional(LOCALE_SDECIMAL, ".")
MsgBox "Format Decimal Lama: " & GetRegional(LOCALE_SDECIMAL)
'Untuk mengganti yg lain bisa pake nilai konstanta diatas _
(disesuaikan dgn kebutuhan)
End Sub
Kamis, 06 November 2008