GetTheLocaleInfo
Gets you Locale information from your machine. It's well freaky because it knows what country you come from!!!!!!
AI
Riepilogo AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Codice sorgente
Public Const LOCALE_USER_DEFAULT = &H400
Public Const LOCALE_IDATE = &H21 ' short date format ordering
Public Const LOCALE_SLANGUAGE = &H2 ' localized name of language
Public Const LOCALE_SCOUNTRY = &H6 ' localized name of country
Public Const LOCALE_SCURRENCY = &H14 ' local monetary symbol
Public Const LOCALE_ILDATE = &H22 ' long date format ordering
Sub GetTheLocaleInfo()
Dim strBuffer As String * 100
Dim lngReturn As Long
Dim strResult As String
Dim msg As String
lngReturn = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IDATE, strBuffer, 99)
strResult = LPSTRToVBString(strBuffer)
Select Case strResult
Case "0":
msg = "mm/dd/yy"
Case "1":
msg = "dd/mm/yy"
Case "2":
msg = "yy/mm/dd"
Case Else:
msg = "#Error#"
End Select
Debug.Print "You are using the " & msg & " short date format"
lngReturn = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILDATE, strBuffer, 99)
strResult = LPSTRToVBString(strBuffer)
Select Case strResult
Case "0":
msg = "mm/dd/yyyy"
Case "1":
msg = "dd/mm/yyyy"
Case "2":
msg = "yyyy/mm/dd"
Case Else:
msg = "#Error#"
End Select
Debug.Print "You are using the " & msg & " Long date format"
lngReturn = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLANGUAGE, strBuffer, 99)
strResult = LPSTRToVBString(strBuffer)
Debug.Print "You are using " & strResult & " language"
lngReturn = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SCOUNTRY, strBuffer, 99)
strResult = LPSTRToVBString(strBuffer)
Debug.Print "You live in " & strResult & "!"
lngReturn = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SCURRENCY, strBuffer, 99)
strResult = LPSTRToVBString(strBuffer)
Debug.Print "You use " & strResult & " as your currency!"
End Sub
Public Function LPSTRToVBString(ByVal s As String) As String
Dim nullpos As Integer
nullpos = InStr(s, Chr(0))
If nullpos > 0 Then
LPSTRToVBString = Left(s, nullpos - 1)
Else
LPSTRToVBString = ""
End If
End Function
Commenti originali (3)
Recuperato da Wayback Machine