Ik heb maar even een efficiëntere code geschreven:
[CPP]If IsNumeric(TextBox2.Text) And IsNumeric(TextBox3.Text) Then
If (CInt(TextBox2.Text) >= 0 And CInt(TextBox2.Text) <= 12) _
And (CInt(TextBox3.Text) >= 1900 And CInt(TextBox3.Text) <= Date.Today.Year) Then
Dim TempJaar As Integer = 0
Dim TempMaand As Integer = 0
If Date.Today.Month < CInt(TextBox2.Text) Then TempJaar = -1 _
Else If Date.Today.Month > CInt(TextBox2.Text) Then TempJaar = 1
If TempJaar = 1 Then TempMaand = Date.Today.Month - CInt(TextBox2.Text) _
Else If TempJaar = -1 Then TempMaand = 12 - (CInt(TextBox2.Text) - Date.Today.Month)
MsgBox("Hallo " & TextBox1.Text & "," & vbNewLine _
& "Je bent " & Date.Today.Year - CInt(TextBox3.Text) + TempJaar & _
" jaar en " & TempMaand & " maand(en) oud.", 64 + 4096, "Leeftijdsmeter")
Else : MsgBox("Ongeldig(e) jaar en/of maand.", 48 + 4096, "Leeftijdsmeter")
End If
Else : MsgBox("Ongeldig(e) jaar en/of maand.", 48 + 4096, "Leeftijdsmeter")
End If[/CPP]
