Reading regional settings (currency)

perlfan

Registered User.
Local time
Today, 01:23
Joined
May 26, 2009
Messages
192
Hi - For several msgbox strings I would like to read the current currency from the regional settings in order to attach the respective currency symbol to different numbers. Is that possible with VBA and - more important - how can I do that?

Thanks for help!! FRANK
 
Hi Frank,

try this:

Code:
  Option Explicit
   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 GetUserDefaultLCID% Lib "kernel32" ()
   Private Const LOCALE_SCURRENCY = &H14
 
Function GetRegionalCurrency() 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)
   End If
 
   GetRegionalCurrency = Symbol
 
End Function

you would call GetRegionalCurrency to retrive the regional currency


cheers

Nidge
 
Great code - works perfectly! Thanks a lot - FRANK
 

Users who are viewing this thread

Back
Top Bottom