The example displays the current date with the Spanish month name in parentheses. The CallbackField "XXXX" is set in the Load event by setting the CustomFormat property to a string that includes the four "X"s. The FormatSize event once before the Forma event and is used to determine the size of the callback field. The Format event then occurs which returns a formatted string to replace the callback field text. To try the example, place a DateTimePicker control on a form and paste the code into the Declarations section.
Option Base 1
Private sSpanishMonthLong(12) As String
Private Sub DTPicker1_Format(ByVal CallbackField As String, FormattedString As String)
If CallbackField = "XXXX" Then
FormattedString = sSpanishMonthLong(DTPicker1.Month)
End If
End Sub
Private Sub DTPicker1_FormatSize(ByVal CallbackField As String, Size As Integer)
Dim iMaxMonthLen As Integer
If CallbackField = "XXXX" Then
iMaxMonthLen = 0
For i = 1 To 12
If iMaxMonthLen < Len(sSpanishMonthLong(i)) Then
iMaxMonthLen = Len(sSpanishMonthLong(i))
End If
Next
End If
Size = iMaxMonthLen
End Sub
Private Sub Form_Load()
DTPicker1.CustomFormat = "MMMM(XXXX) dd, yyy"
DTPicker1.Format = dtpCustom
sSpanishMonthLong(1) = "Enero"
sSpanishMonthLong(2) = "Febrero"
sSpanishMonthLong(3) = "Marzo"
sSpanishMonthLong(4) = "Abril"
sSpanishMonthLong(5) = "Mayo"
sSpanishMonthLong(6) = "Junio"
sSpanishMonthLong(7) = "Julio"
sSpanishMonthLong(8) = "Agosto"
sSpanishMonthLong(9) = "Septiembre"
sSpanishMonthLong(10) = "Octubre"
sSpanishMonthLong(11) = "Noviembre"
sSpanishMonthLong(12) = "Diciembre"
End Sub