我在if条件下得到错误(我在日期差异中猜测),但我无法想到原因。
错误说明:无效的过程调用或参数。
现在:当前系统时间格式为DD.MM.YYYY HH:MM:SS
datum:表格中的日期格式为DD.MM.YYYY HH:MM:SS
Public Function ImportDateCheckSpec(eing As String) As error
Dim datum As Date
Dim error As New error
error.Success = True
error.Code = 2
error.Message = "There has been a problem with the given Date. This might be due to:" + vbCrLf + " *The date is befor the current date. " + vbCrLf + " *The date is in the wrong format."
Debug.Print 4
On Error GoTo Fail
datum = CDate(eing)
Debug.Print datum
Debug.Print Now
If (DateDiff("Day", Now, datum) < 0) Then '<----- Here is the error
Debug.Print 2
error.Success = False
Set ImportDateCheckSpec = error
End If
Exit Function
Fail:
Debug.Print 3
error.Success = True
Set ImportDateCheckSpec = error
Exit Function
End Function
答案 0 :(得分:1)
您的参数在DateDiff上不正确。试试这个:
If (DateDiff("d", Now, datum) < 0) Then '<----- Here is the error