Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Calcolo età in giorni - Form1.vb

Form1.vb

Caricato da: Albertking82
Scarica il programma completo

  1. Public Class Form1
  2.     Dim datacur As Date, datanascita As Date, giorni As Long
  3.     Private Sub cmdcalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdcalc.Click
  4.         If txtdata.Text = "" Then
  5.             Exit Sub
  6.         End If
  7.         If Not IsDate(txtdata.Text) Then
  8.             MsgBox("Formato data non corretto!", MsgBoxStyle.Information, "Errore input")
  9.         Else
  10.  
  11.             datacur = DateTime.Today.Date
  12.             datanascita = CDate(txtdata.Text)
  13.             giorni = DateDiff(DateInterval.Day, datacur, datanascita)
  14.             giorni = System.Math.Abs(giorni)
  15.             txtdata.Text = "Tu hai " & CStr(giorni) & " giorni di vita"
  16.         End If
  17.  
  18.     End Sub
  19.  
  20.     Private Sub cmdcanc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdcanc.Click
  21.         txtdata.Text = ""
  22.         txtdata.Focus()
  23.     End Sub
  24. End Class