Private Sub Command1_Click()
If Option1.Value = True Then
Text2.Text = ConvertDateString(Text1.Text, 1, 0, "dd/mm/yyyy")
Else
Text2.Text = ConvertDateString(Text1.Text, 0, 1, "dd/mm/yyyy")
End If
End Sub
Function ConvertDateString( _
ByRef StringIn As String, _
ByRef OldCalendar As Integer, _
ByVal NewCalendar As Integer, _
ByRef NewFormat As String) As String
Dim SavedCal As Integer
Dim d As Date
Dim s As String
'// Save VBA Calendar setting to restore when finished
SavedCal = Calendar
'// Convert date to new calendar and format
Calendar = OldCalendar ' Change to StringIn calendar
d = CDate(StringIn) ' Convert from String to Date
Calendar = NewCalendar ' Change to calendar of new string
s = CStr(d) ' Convert to short format String
ConvertDateString = Format(s, NewFormat)
'// Restore VBA Calendar setting
Calendar = SavedCal
End Function
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
If VBA.Calendar = vbCalGreg Then
Option2.Value = True
Else
Option1.Value = True
End If
Text1.Text = Date
End Sub