我已经得到了开始日期来验证是否在结束日期之后并显示消息,但是当我输入以下代码时,它似乎运行了两次代码我已经尝试了所有的句柄离开尝试它没有工作我也把它进入一个新线程,没有工作,也进入一个函数,我在这个问题上没有工作
这是代码
Function DateCompare(ByVal Start As Date, ByVal Finish As Date, ByVal WhichDate As String)
If WhichDate = "DateIn" Then
If DateTime.Compare(Start, Finish) > 0 Then
MsgBox("Dates Are Invalid : Date In Cannot be after Date Out, Please Amend", vbExclamation, "Dates Are Incorrect")
Return False
Exit Function
Else
Return True
End If
Else
If DateTime.Compare(Finish, Start) < 0 Then
MsgBox("Dates Are Invalid : Date Out Cannot be before Date In, Please Amend", vbExclamation, "Dates Are Incorrect")
Return False
Exit Function
Else
Return True
End If
End If
End Function
Private Sub dtpDateTimeIn_leave(ByVal sender As Object, ByVal e As EventArgs) Handles dtpDateTimeIn.Leave
Dim result As Boolean
result = DateCompare(dtpDateTimeIn.Value, dtpDateTimeOut.Value, "DateIn")
If result = False Then
dtpDateTimeIn.Focus()
End If
End Sub
Private Sub dtpDateTimeOut_leave(ByVal sender As Object, ByVal e As EventArgs) Handles dtpDateTimeOut.Leave
Dim result As Boolean
result = DateCompare(dtpDateTimeIn.Value, dtpDateTimeOut.Value, "DateOut")
If result = False Then
dtpDateTimeOut.Focus()
End If
End Sub