AgeCalc




Function Agecal(myDate As Variant) As Integer
myDate = CDate(Text1)
Dim Totdays As Long
Totdays = DateDiff("y", myDate, Date) ' Numero totale giorni
Step1 = Abs(Totdays / 365.25) ' Number anni
Step2 = (Step1 - Int(Step1)) * 365.25 / 30.435 ' Numero mesi
Step3 = CInt((Step2 - Int(Step2)) * 30.435) ' Numeero giorni
If myDate < Date Then
Label1 = "Hai:" & Int(Step1) & " Anni " & Int(Step2) & " mesi " &
Int(Step3) & " Giorni"
Else
Label1 = " Hai:" & Int(Step1) & " Anni " & Int(Step2) & " Mesi " &
Int(Step3) & " Giorni"
End If
End Function

Private Sub Command1_Click()
If IsDate(Text1) = False Then
MsgBox " Inserire una data valida. "
Text1.SetFocus
Text1.SelStart = 0:Text1.SelLength = Len(Text1)
Exit Sub
End If
Agecal (myDate)
End Sub

Richiede l'inserimento di una Data










( agecalc.html )- by Paolo Puglisi - Modifica del 17/12/2023