Public Class Form1
Dim datacur As Date, datanascita As Date, giorni As Long
Private Sub cmdcalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdcalc.Click
If txtdata.Text = "" Then
Exit Sub
End If
If Not IsDate(txtdata.Text) Then
MsgBox("Formato data non corretto!", MsgBoxStyle.Information, "Errore input")
Else
datacur = DateTime.Today.Date
datanascita = CDate(txtdata.Text)
giorni = DateDiff(DateInterval.Day, datacur, datanascita)
giorni = System.Math.Abs(giorni)
txtdata.Text = "Tu hai " & CStr(giorni) & " giorni di vita"
End If
End Sub
Private Sub cmdcanc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdcanc.Click
txtdata.Text = ""
txtdata.Focus()
End Sub
End Class