Private Sub Command1_Click()
On Error GoTo abc
Dim Newtime As Single, TDate As String, TDate1 As Date
TDate = InputBox("请输入结束时间,格式为YYYY-MM-DD HH:MM:SS", "输入框")
TDate1 = CDate(TDate)
'计算的秒数,存储在变量Newtime中。
Newtime = DateDiff("s", TDate1, Now)
'输出提示
Label1.Caption = "从" & TDate & "到" & CStr(Now) & "剩余的秒数为" & CStr(Newtime) & "秒。"
Exit Sub
'如果输入的时间有错误,执行下面的代码
abc:
MsgBox "输入的时间格式有错误,程序不能继续!", 16, "错误!"
End Sub