hi. i'm a newbie here, and an amateur in programming. i was wondering if you could help me answer my problem with the program that i'm writing. i'm using 3 NumericUpDown controls to get an output and convert it to a Date. i don't know if i am doing this right, and i've been working on this overnight. i'll put the codes that i've written:
Private Sub btnDaysOld_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDaysOld.Click
Dim shoMonth As Short
Dim shoDay As Short
Dim shoYear As Short
Dim strBirthday As String
Dim datBirthday As Date
Dim lngDaysOld As Long
shoMonth = Convert.ToString(nudBirthMonth.Value)
shoDay = Convert.ToString(nudBirthDay.Value)
shoYear = Convert.ToString(nudBirthYear.Value)
strBirthday = shoMonth.ToString & shoDay.ToString & shoYear.ToString
datBirthday = Date.Parse(strBirthday).ToShortDateString
lngDaysOld = DateDiff(DateInterval.Day, datBirthday, Today)
lblDaysOld.Text = lngDaysOld.ToString
End Sub
i'm trying to get the interval days between the two Dates (the Date today, and my birthday). the bolded texts are the ones that i want to know if i'm doing the right thing. because when i run the program, the error says "Format Exception was unhandled: String was not recognized as a valid DateTime".
how can i combine the output from those nud controls to convert it to a string, and then to a Date? i would greatly appreciate your help to solve my problem. Thanks..
Private Sub btnDaysOld_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDaysOld.Click
Dim shoMonth As Short
Dim shoDay As Short
Dim shoYear As Short
Dim strBirthday As String
Dim datBirthday As Date
Dim lngDaysOld As Long
shoMonth = Convert.ToString(nudBirthMonth.Value)
shoDay = Convert.ToString(nudBirthDay.Value)
shoYear = Convert.ToString(nudBirthYear.Value)
strBirthday = shoMonth.ToString & shoDay.ToString & shoYear.ToString
datBirthday = Date.Parse(strBirthday).ToShortDateString
lngDaysOld = DateDiff(DateInterval.Day, datBirthday, Today)
lblDaysOld.Text = lngDaysOld.ToString
End Sub
i'm trying to get the interval days between the two Dates (the Date today, and my birthday). the bolded texts are the ones that i want to know if i'm doing the right thing. because when i run the program, the error says "Format Exception was unhandled: String was not recognized as a valid DateTime".
how can i combine the output from those nud controls to convert it to a string, and then to a Date? i would greatly appreciate your help to solve my problem. Thanks..