Visual Basic 6.0 IF 语句不会通过,只会继续执行 ELSE 语句

Eli*_*eis -1 vb6

我正在尝试使用 IF 语句比较 2 个日期,但似乎 Visual Basic 不会比较它们,因为我总是以 Else 上的 msgbox 结束,这是我的代码:

If Format(theSysDT, "mm/dd/yyyy HH:MM:SS") > Format(CLParamDL, "mm/dd/yyyy HH:MM:SS") Then
        MsgBox ("theSysDt is greater than CLParamDL")
Else
        MsgBox ("error error")
End If
Run Code Online (Sandbox Code Playgroud)

theSysDT: 06/21/2021, 15:22:35

CLParamDL: 09/21/2017, 17:02:00

我不知道为什么它不会进入 IF 语句。

Slu*_*sie 5

假设 SysDT 和 CLParamDL 都是 Date 类型,那么只需比较它们而不尝试将它们转换为字符串:

If theSysDT > CLParamDL Then
    MsgBox ("theSysDt is greater than CLParamDL")
Else
    MsgBox ("error error")
End If
Run Code Online (Sandbox Code Playgroud)