Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Monday, July 25, 2011

VB-65 : Application to calculate your age

Develop an application that accepts input from the user (a birth date) and calculates the person's age.It should display exact age(years,months and days).


To set Date, we need a controll called DtPicker.
To add DtPicker , select Project--> Components--> Microsoft Window common control-2.6.0



(A)Program Design : 


(B) Property(Controls Used) :
  • 2 Labels with Captions as Date of Birth & Age  (Name- lbl_dob and lbl_age)
  • The control DtPicker (Name DtPicker1) near to label1 "Date of Birth"
  • One Text Box to display the calculated age
(C) Attaching Code to the Object :

Dim days As variant
Private Sub DTPicker1_change()
Dim d_diff, m_diff, y_diff As Integer
y_diff = Year(Date) - DTPicker1.Year
m_diff = Month(Date) - DTPicker1.Month
d_diff = Day(Date) - DTPicker1.Day
If Date < DTPicker1.Value Then
MsgBox "Enter Past Date"
Else
If d_diff < 0 Then
d_diff = d_diff + days(Month(Date) - 1)
m_diff = m_diff - 1
End If
If m_diff < 0 Then
m_diff = m_diff + 12
y_diff = y_diff - 1
End If
Text1.Text = y_diff & "years," & m_diff & "month,and" & d_diff & "days"
End If
End Sub
Private Sub Form_Load()
days = Array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
End Sub



      • ====================================================================
        Back to Home   &  VB
    ===========================================================