Age Calculator

Topic Progress

How old are you in years, months, minutes, seconds?

To make the age calculator you will need

  • 6 labels
  • 4 textboxes
  • 1 button

Double click the button ad copy and paste the following code

1
2
3
4
5
6
7
8
9
10
11
  Dim a As String
  Dim b As String
  Dim c As String
  a = TextBox3.Text
  b = TextBox1.Text
  c = TextBox2.Text
   Dim DOB As New DateTime(a, b, c)
   Dim Years As Integer = DateDiff(DateInterval.Year, DOB, Now) - 1
   Dim Months As Integer = DateDiff(DateInterval.Month, DOB, Now) Mod 12
   Dim days As Integer = DateDiff(DateInterval.Day, DOB, Now) Mod 30 - 10
   TextBox4.Text = Years & " Years, " & Months & " Months "

Quiz challenge

One of the most important days in history for computing is in the app below. Can you work out what it is?

Click on this link for a clue CLue

This app was run on 04/10/2017

Code Challenge

Its your turn to find out how old the above are

You need 1 extra textbox

How many days in a year, hours in a day ?Minutes in a day?

Add to the code and try and work it out

If you get stuck you can take a peek at the code by clicking on the next slide