The Locale-module is a must have for all who works with projects that must handle different language locales at once, without being bound by the computers locale-setting. In this module you will find functions to convert different datatypes back and forth to strings as well as functions to validate strings against different datatypes.
Be the first to leve a comment or ask a question about the code!
Here is an example how to use it:
Dim D As Date
Dim S As String
Dim LanguageID As Long
Dim LCID As Long
LanguageID = MakeLanguageID(LANG_ENGLISH, SUBLANG_ENGLISH_US)
LCID = MakeLCID(LanguageID, SORT_DEFAULT)
D = Now
S = FormatLocaleDateTime(LCID, D)
Debug.Print S
If IsLocaleDate(LCID, S) Then
D = ParseLocaleDate(LCID, S)
Debug.Print D
Else
Debug.Print "Illegal date string"
End If
The interface:
- FormatLocaleDateTime(ByVal LCID As Long, ByVal Expression As Date) As String
Converts a date-variable to a string containing the date and time in the given locale.
- FormatLocaleDate(ByVal LCID As Long, ByVal Expression As Date) As String
Converts a date-variable to a string containing only the date in the given locale.
- FormatLocaleTime(ByVal LCID As Long, ByVal Expression As Date) As String
Converts a date-variable to a string containing the time in the given locale.
- FormatLocaleLong(ByVal LCID As Long, ByVal Expression As Long) As String
Converts a long-variable to a string in the given locale.
- FormatLocaleDouble(ByVal LCID As Long, ByVal Expression As Double, Optional ByVal NumDigits As Long = 2) As String
Converts a double-variable to a string in the given locale.
- FormatLocaleCurrency(ByVal LCID As Long, ByVal Expression As Currency, Optional ByVal NumDigits As Long = 2) As String
Converts a currency-variable to a string in the given locale.
- FormatLocaleBoolean(ByVal LCID As Long, ByVal Expression As Boolean) As String
Converts a boolean-variable to a string in the given locale.
- GetLocaleInformation(ByVal LCID As Long, ByVal LCType As LocaleInfoEnum) As String
Retrives information about a locale.
- GetDLLErrorDescription(ByVal ErrorNo As Long, ByVal LCID As Long) As String
Gets the DLL error message for a given error in the given locale.
Use this to show system error-messages in any language.
- ParseLocaleBoolean(ByVal LCID As Long, ByVal Expression As String) As Boolean
Parses a string in the given locale to a boolean-variable.
- IsLocaleBoolean(ByVal LCID As Long, ByVal Expression As String) As Boolean
Tests a string to see if it's a valid boolean-value in the given locale.
- ParseLocaleCurrency(ByVal LCID As Long, ByVal Expression As String) As Currency
Parses a string in the given locale to a Currency-variable.
- IsLocaleCurrency(ByVal LCID As Long, ByVal Expression As String) As Boolean
Tests a string to see if it's a valid currency-value in the given locale.
- ParseLocaleDate(ByVal LCID As Long, ByVal Expression As String) As Date
Parses a string in the given locale to a date-variable.
- IsLocaleDate(ByVal LCID As Long, ByVal Expression As String) As Boolean
Tests a string to see if it's a valid date-value in the given locale.
- ParseLocaleDouble(ByVal LCID As Long, ByVal Expression As String) As Double
Parses a string in the given locale to a double-variable.
- IsLocaleDouble(ByVal LCID As Long, ByVal Expression As String) As Boolean
Tests a string to see if it's a valid double-value in the given locale.
- GetFloatRegEx(ByVal LCID As Long) As String
Returns a string containing a regex expression to validate if a string is a valid float-value in the given locale.
- GetIntegerRegEx(ByVal LCID As Long) As String
Returns a string containing a regex expression to validate if a string is a valid integer-value in the given locale.
- GetJScriptParseLocaleDouble(ByVal LCID As Long)
Returns a string containing jscript to parse a string in the given locale to a double-variable.
- MakeLanguageID(ByVal usPrimaryLanguage As Long, usSubLanguage As Long) As Long
Creates a LanguageID.
- MakeLCID(ByVal wLanguageID As Long, ByVal wSortID As Long)
Creates a LCID (Locale ID).