我有这个功能:
Public Function checkstring(ByVal AnyDateString As Date) As Date
Dim ResDate As String
Dim Yr As String
Dim Mt As String
Dim Dt As String
Dim format As String
Dim provider As System.Globalization.CultureInfo = System.Globalization.CultureInfo.InvariantCulture
Yr = Year(AnyDateString)
Mt = Month(AnyDateString)
Dt = Microsoft.VisualBasic.DateAndTime.Day(AnyDateString)
ResDate = Mt & "/" & Dt & "/" & Yr
format = "MM/dd/yyyy"
checkstring = Date.ParseExact(DateString, format, provider)
End Function
当我运行它时显示此错误:
字符串未被识别为有效的DateTime
我确实需要将ResDate
字符串存储为格式为MM/dd/yyyy
的日期。