' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Imports System
Imports System.Globalization

Module Program
    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
    Sub Main()
        Console.WriteLine(Age("090906-1234"))
        Console.WriteLine(Age("100906-1234"))
        Console.WriteLine(Age("110906-1234"))
        Console.WriteLine(Age("110959-1234"))
        Console.WriteLine(Age("110957-1234"))
        Console.WriteLine(Age("110951-1234"))
        Console.WriteLine(Age("110949-1234"))
        Console.WriteLine(Age("110941-1234"))
        Console.WriteLine(Age("110939-1234"))
        Console.WriteLine(Age("110931-1234"))
        Console.WriteLine(Age("110930-1234"))
        Console.WriteLine(Age("110929-1234"))
    End Sub
End Module
