양식이 VB6으로 작성되어 있으며 이후 날짜의 날짜 필드를 확인해야합니다.Visual Basic 6 : 날짜가 미래에 있는지 확인하십시오.
입력 한 날짜가 미래의 경우 오류 메시지가 표시되어야하고 그렇지 않은 경우 유효성 검사가 완료되어야합니다.
은 내가했던 :
Format(txtDate(9).Text, "dd/mm/yyyy") > Date
은 항상 :
txtDate(9).Text > Date
내가 할 경우에도 항상
사실 때문에
Private Sub txtDate_Validate(Index As Integer, Cancel As Boolean)
If Not IsDate(txtDate(9).Text) Then 'first I check if the data entered is a date
'error message saying the field needs a valid date
Cancel = True
Else
If (txtDate(9).Text > Date) Then 'now I check if the date entered is bigger than today’s date
'error message saying the date is in the future
Cancel = True
Else
Exit Sub
End If
End If
End If
End Sub
이 코드가 작동하지 않습니다 true too
문제를 해결하려면 어떻게해야합니까? 입력 한 날짜가 미래에 있는지 어떻게 알 수 있습니까?
감사합니다.
txtDate (9) .text를 날짜로 변환하십시오. 프로그래밍 규칙 # 356, 문자열로 날짜 계산을하지 마십시오. –
Cdate, 찾았습니다! 의견을 받아 들일 수 있도록 게시물을 작성하십시오. 고마워, VB6 학습자 여기! – user523129
이상하게도, 당신은 [지난 번에 말 했었습니다] (http://stackoverflow.com/questions/14558797/vb6-validating-date-with-a-a-format#comment20315498_14558797) :) – Deanna