Option Explicit
'Developed by Paul_Hossler and SamT
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
Public Const LOCALE_USER_DEFAULT As Long = &H400
Public Const LOCALE_SABBREVLANGNAME As Long = &H3
Public aMonthNames As Variant
Public MonthWord As String
Public aDayNumbers As Variant
Public DayWord As String
Public Const U_caron As Long = &H16B
Public Const Z_caron As Long = &H17E
Public Const E_caron As Long = &H117
Public Const S_caron As Long = &H161
Public Const C_caron As Long = &H10D
Sub driver()
MsgBox SpecialDateFormat(DateSerial(2015, 11, 20)) 'use UserForm1
End Sub
Function SpecialDateFormat(Dt As Date)
SetArrays
SpecialDateFormat = _
aMonthNames(Month(Dt) - 1) & _
" " & MonthWord & _
" " & aDayNumbers(Day(Dt) - 1) & _
" " & DayWord
End Function
Private Function SetArrays()
Dim sLang As String
Dim i As Long
sLang = GetInfo(LOCALE_SABBREVLANGNAME)
Select Case sLang
Case "LTH"
aMonthNames = Array("sausio", "vasario", "kovo", "baland" & ChrW(Z_caron) & "io", "gegu" & ChrW(Z_caron) & ChrW(E_caron) & "s", "bir" & ChrW(Z_caron) & "elio", _
"liepos", "rugpj" & ChrW(U_caron) & ChrW(C_caron) & "io", "rugs" & ChrW(E_caron) & "jo", "spalio", "lapkri" & ChrW(C_caron) & "io", "gruod" & ChrW(Z_caron) & "io")
MonthWord = "m" & ChrW(E_caron) & "nesio"
aDayNumbers = Array("pirma", "antra", "tre" & ChrW(C_caron) & "ia", "ketvirta", "penkta", ChrW(S_caron) & "e" & ChrW(S_caron) & "ta", "septinta", _
"a" & ChrW(S_caron) & "tunta", "devinta", "de" & ChrW(S_caron) & "imta", "vienuolikta", "dvylikta", "trylikta", "keturiolikta", "penkiolikta", _
ChrW(S_caron) & "e" & ChrW(S_caron) & "iolikta", "septyniolikta", "a" & ChrW(S_caron) & "tuoniolikta", "devyniolikta", "dvidešimta", "dvidešimt pirma", "dvidešimt antra", _
"dvidešimt tre" & ChrW(C_caron) & "ia", "dvidešimt ketvirta", "dvidešimt penkta", "dvidešimt šešta", "dvidešimt septinta", _
"dvidešimt aštunta", "dvidešimt devinta", "trisdešimta", "trisdešimt pirma")
DayWord = "diena"
Case "ENU"
aMonthNames = Array("January", "February", "March", "April", "May", "June", _
"July", "Auguet", "September", "October", "November", "December")
MonthWord = "month"
aDayNumbers = Array("first", "second", "third", "fourth", "fifth", "sixth", "seventh", _
"eighth", "ninth", "tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", _
"sixteenth", "seventeenth", "eighteenth", "nineteenth", "twentieth", "twenty-first", "twenty-second", _
"twenty-third", "twenty-fourth", "twenty-fifth", "twenty-sixth", "twenty-seventh", _
"twenty-eighth", "twenty-ninth", "thirtieth", "thirty-first")
DayWord = "day"
Case Else
MsgBox "Oops"
End Select
End Function
Private Function GetInfo(ByVal lInfo As Long) As String
Dim Buffer As String
Dim ret As String
Buffer = String$(256, 0)
ret = GetLocaleInfo(LOCALE_USER_DEFAULT, lInfo, Buffer, Len(Buffer))
If ret > 0 Then
GetInfo = Left$(Buffer, ret - 1)
Else
GetInfo = vbNullString
End If
lbl_Exit:
Exit Function
End Function
The code of the UserForm1