Create a form which has three radio buttons for age in year, age in days and age in months. Enter date of birth in a textbox and display appropriate result in another textbox. Also find date of death (assumeaverage age of 62).
Code:
PublicClass app
Dim bod AsDate
Dim lifeTime As TimeSpan
Dim lifeDays, lifemonths, lifeyears AsInteger
Dim ddate As DateTime
PrivateSub CountB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CountB.Click
Try
bod = Date.Parse(Me.DOBTB.Text)
lifeTime = Now.Subtract(bod)
lifeDays = lifeTime.Days
lifeyears = lifeTime.Days / 365
lifemonths = lifeTime.Days / 31
ddate = bod.AddYears(62)
Me.DDTB.Text = ddate
Catch ex As Exception
EndTry
EndSub
PrivateSub DaysR_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DaysR.CheckedChanged, yearsR.CheckedChanged, monthsR.CheckedChanged
Try
'HANDLES CHECK CHANGED EVENT OF ALL RADIO CONTROLS
If DaysR.Checked = TrueThen
Me.AGETB.Text = lifeDays &" Days"
ElseIf monthsR.Checked = TrueThen
Me.AGETB.Text = lifemonths &" Months"
ElseIf yearsR.Checked = TrueThen
Me.AGETB.Text = lifeyears &" Years"
EndIf
Catch ex As Exception
EndTry
EndSub
EndClass
Made By: Mudassir Malik (Microsoft Student Partner)
Comments
Post a Comment