需要关于这个逻辑的帮助......(.NET)

Whi*_*tey 1 .net errorprovider

这是我在我的形式来检查的日期选择的用户超过14天前,或在过去的代码.

If (dtpDate.Value > DateTime.Today.AddDays(14)) Then
    frmBookErr.SetError(dtpDate, "You cannot book more than two weeks in advance.")
Else
    frmBookErr.SetError(dtpDate, "")
End If
If (dtpDate.Value < DateTime.Today) Then
    frmBookErr.SetError(dtpDate, "You cannot book a room for the past.")
Else
    frmBookErr.SetError(dtpDate, "")
End If
Run Code Online (Sandbox Code Playgroud)

它的工作原理,但如果我选择提前14天以上的日期也不会显示错误消息,第二,因为如果检查如果是在过去,它消隐.

我实在想不出另一种方式解决这个除了让另一个文本框坐在后面的一个用户类型分为,并显示第二个错误消息的那一个.

有人有什么好主意吗?谢谢 :)

Jos*_*ein 8

试试这个

If (dtpDate.Value > DateTime.Today.AddDays(14)) Then
    frmBookErr.SetError(dtpDate, "You cannot book more than two weeks in advance.")
Else If (dtpDate.Value < DateTime.Today) Then
    frmBookErr.SetError(dtpDate, "You cannot book a room for the past.")
Else
    frmBookErr.SetError(dtpDate, "")
End If
Run Code Online (Sandbox Code Playgroud)