We have a a VB6 app (in a COM component) which uses CDate() to take a string and cast it to a Date, for storing in a database.
Depending on if we want the applicatio
Another way to go:
Public Enum abDateType
abMDY
abDMY
End Enum
Public Function MakeDate(ByVal dateString As String, ByVal dateType As abDateType, Optional delimiter As String = "/") As Date
Dim strVals() As String
Dim dtRtnVal As Date
strVals = Split(dateString, delimiter)
Select Case dateType
Case abMDY
dtRtnVal = DateSerial(strVals(2), strVals(0), strVals(1))
Case abDMY
dtRtnVal = DateSerial(strVals(2), strVals(1), strVals(0))
Case Else
Err.Raise vbObjectError, , "Unexpected date format."
End Select
MakeDate = dtRtnVal
End Function