PDA

View Full Version : How do I make an age calculator using microsoft VB 6.0 that shows how many days...


Jonathan M
10-08-2007, 08:49 PM
...have been lived? (pc class hw) I need the code for it, I can't figure out how to invent my own :( how do I learn to make my own VB code, but really get it to work the way I want it to?

SquirrelNutz
10-08-2007, 08:49 PM
Create a form with 2 text boxes named: txtDOB and txtDaysLived. Add a command button named btnCalculate to the form. Add labels for the text boxes accordingly.

Add the following code to the form code module for the btnCalculate_Click event:

Private Sub btnCalculate_Click()
txtDaysLived = Date - CDate(txtDOB)
End Sub

This is an overly simple version of a days lived calculator - but it works perfectly well - calculating a person's DOB (date of birth) from today's date.

Good luck!