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
DateAdd
accepts a wide variety of inputs and outputs in the correct format.
ThisLine = "Tuesday, September 04, 2012 2:02 PM"
i = InStr(ThisLine, ",") ' get rid of the leading day
If i > 0 Then
TempResult = Trim(Right$(ThisLine, Len(ThisLine) - i))
end if
TempResult = DateAdd("s", 0, TempResult)
I don't know of an easy solution. You could Split the input string into sub-strings by the delimiter, and then use DateSerial to recombine the year, month and hour numbers into a native VB6 Date variable. Something like this below. If you need to support a lot of locales, this could get complicated (see Bob's answer). Mind you, so would using DateTime.ParseExact.
sInput = "1/3/71"
Dim splt() As String
splt = Split(sInput, "/")
dte = DateSerial(splt(2) + 1900, splt(1), splt(0)) ' dd/mm/yy'