Function getDatefromLine(strLine As String) As String
Dim strArry() As String
Dim strDay As String, strTime As String
Dim nargs As Integer
Dim objdate As Date
strArry = Split(strLine)
nargs = UBound(strArry)
strDay = strArry(nargs - 2)
strTime = strArry(nargs - 1)
If InStr("AMPM", strArry(nargs)) > 0 Then strTime = strTime & " " & strArry(nargs)
getDatefromLine = Format(CDate(strDay) & " " & strTime, "yyyy/mm/dd HH:mm:00")
End Function
Mình viết function như trên để lấy ngày giờ của hệ thống.
Khi run thì báo lỗi "Run-time error 13: Type mismatch" ở dòng:
"getDatefromLine = Format(CDate(strDay) & " " & strTime, "yyyy/mm/dd HH:mm:00")"
Nhờ mọi người giải thích dùm.
Thanks!
Dim strArry() As String
Dim strDay As String, strTime As String
Dim nargs As Integer
Dim objdate As Date
strArry = Split(strLine)
nargs = UBound(strArry)
strDay = strArry(nargs - 2)
strTime = strArry(nargs - 1)
If InStr("AMPM", strArry(nargs)) > 0 Then strTime = strTime & " " & strArry(nargs)
getDatefromLine = Format(CDate(strDay) & " " & strTime, "yyyy/mm/dd HH:mm:00")
End Function
Mình viết function như trên để lấy ngày giờ của hệ thống.
Khi run thì báo lỗi "Run-time error 13: Type mismatch" ở dòng:
"getDatefromLine = Format(CDate(strDay) & " " & strTime, "yyyy/mm/dd HH:mm:00")"
Nhờ mọi người giải thích dùm.
Thanks!