Hi i have an assignment I’m working on. I have to let the user input their date of birth and then the program will print its age. I don’t know a lot about VB so if there is an easy way to do this. Thanks for the help.
From looking around on the site i got about this far
Sub Main()
Dim Bday As Date
Console.WriteLine("What is your date of birth?")
Bday = Console.ReadLine
Dim d1 As Date
Dim d2 As Date
d1 = Now
d2 = Bday
Dim iage As Integer
iage = DateDiff(DateInterval.Year, d2, d1)
Console.WriteLine(iage)
Console.ReadKey()
End Sub
It doesnt work right though cuz i enter my Bday as 6/30/1993
and it says im 18. Im actually about 17 and a half..
I changed it to
Dim Bday As Date
Console.WriteLine("What is your date of birth?")
Bday = Console.ReadLine
Dim d1 As Date
Dim d2 As Date
d1 = Now
d2 = Bday
Dim iage As Integer
Dim Years As Integer
iage = DateDiff(DateInterval.Year, d2, d1)
Years = iage - 1
Console.WriteLine(Years)
Console.ReadKey()
it seems to work like this