Function Age(s As String) As Integer Dim birthday As DateTime = DateTime.ParseExact(s.Substring(0, 6), "ddMMyy", CultureInfo.InvariantCulture) Dim today As DateTime = DateTime.Now If now.Month > birthday.Month Or (now.Month = birthday.Month And now.Day >= Birthday.Day) Then Return today.Year - birthday.Year Else Return today.Year - birthday.Year - 1 End If End Function
Function Age(s As String) As Integer Dim birthday As DateTime = DateTime.ParseExact(s.Substring(0, 6), "ddMMyy", CultureInfo.InvariantCulture) Dim today As DateTime = DateTime.Now Dim n As Integer If now.Month > birthday.Month Or (now.Month = birthday.Month And now.Day >= Birthday.Day) Then n = today.Year - birthday.Year Else n = today.Year - birthday.Year - 1 End If n = (n + 100) Mod 100 Return n End Function
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.