Я использую datediff
для отображения dateofbirth
. Может ли кто-нибудь помочь мне в том, как и где добавить msgbox("Sorry, INVALID date of BIRTH")
?как добавить leapyear в DOB с использованием lateiff
Это мой код и где ошибка происходит без messagebox
.
Dim i As New Integer
Private Function IsLeapYear(ByVal intYear As Integer) As Boolean
IsLeapYear = (Month(DateSerial(i, 2, 29)) = 2)
End Function
Private Sub ComboMonth_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboMonth.SelectedIndexChanged
' cboMonth.Items.Clear()
If Me.cboMonth.Text = "February" Then
For i = 1 To 28
cboDay.Items.Add(i)
Next
ElseIf Me.cboMonth.Text = "January" Or Me.cboMonth.Text = "March" Or Me.cboMonth.Text = "May" Or Me.cboMonth.Text = "July" Or Me.cboMonth.Text = "September" Or Me.cboMonth.Text = "November" Then
For i = 1 To 31
cboDay.Items.Add(i)
Next
ElseIf Me.cboMonth.Text = "April" Or Me.cboMonth.Text = "June" Or Me.cboMonth.Text = "August" Or Me.cboMonth.Text = "October" Or Me.cboMonth.Text = "December" Then
For i = 1 To 30
cboDay.Items.Add(i)
Next
End If
End Sub
Private Sub cboYear_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboYear.SelectedIndexChanged
Dim dob As Date
Dim today As Long
dob = Me.cboMonth.Text & "-" & Me.cboDay.Text & "-" & Me.cboYear.Text 'here error says date is not valid
today = DateDiff(DateInterval.Day, dob, Now)/365
Me.txtAge.Text = today
End Sub
Sub years()
For i = 1950 To 2050
cboYear.Items.Add(i)
Next
End Sub
Sub days()
For i = 1 To 31
cboDay.Items.Add(i)
Next
End Sub
'newDt = oldDt.AddYears (n)' – Plutonix