Write a program in VBto read your Date Of Birth (DOB) , take current date from the system and then find your age :
Refer Application to calculate your age also.
To set Date, we need a controll called DtPicker.
To add DtPicker , select Project--> Components--> Microsoft Window common control-2.6.0
(B) Property(Controls Used) :
- DtPicker
- One Command Button (Find Age)
- 3 TextBoxes (To display Years,Months and Days)
(C) Attaching Code to the Object :
Private Sub Command1_Click() Dim dob, today, y, m, d dob = CDate(DTPicker1) today = Now() y = DateDiff("yyyy", dob, today) Text1.Text = y m = DateDiff("m", dob, today) Mod 12 Text2.Text = m d = DateDiff("d", dob, today) - ((y - 1) * 365) - (m * 30) Text3.Text = d End Sub |
(D) Output :
(E) Errors :
If found any errors while running your VB program, or want to put your comment about any program , please click Comment section , to post.
- ====================================================================
No comments:
Post a Comment