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

Sunday, August 7, 2011

VB-84 : Read your DOB and find your age.


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

(A)Program Design : 


(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.


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

    No comments: