Page 1 sur 1
Calculer l'age

Publié:
06 Nov 2007 à 14:21
par Michael DELIQUE
- Code : Tout sélectionner
Public Function Calcul_Age(wDate As String) As Double
'renvois le nombre d'année entr la date passé en paramatere et la date systeme.
'si le nombre d'anneé est zéro renvois le nombre de mois sous la forme 0.6 = six mois
'wdate correspondant a la date de naissance
'Déclaration Variable
Dim dteValue As NotesDateTime
Dim dteNow As NotesDateTime
On Error Goto ErreurHandle
If Trim(wDate) = "" Then
Error 9999,"wDate vide"
Exit Function
End If
Set dteValue = New NotesDateTime(wDate)
Set dteNow = New NotesDateTime(Now)
If dteNow.TimeDifference(dteValue)<=0 Then
Set dteValue = Nothing
Set dteNow = Nothing
Calcul_Age = 0
Exit Function
End If
Calcul_Age = Year(dteNow.DateOnly)-Year(dteValue.DateOnly)
Set dteNow = Nothing
If Calcul_Age = 0 Then
If Month(dteValue.DateOnly)>9 Then
Calcul_Age = Month(dteValue.DateOnly)/100
Else
Calcul_Age = Month(dteValue.DateOnly)/10
End If
End If
Set dteValue = Nothing
Exit Function
ErreurHandle:
Set dteValue = Nothing
Set dteNow = Nothing
Msgbox "("+Cstr(Getthreadinfo (1))+" Call by "+Cstr(Getthreadinfo(10))+")"+Chr(10)+"Erreur " + Str(Err) + " : "+Chr(10) + Cstr(Error)+". "+Chr(10)+"Ligne N° "+Cstr(Erl),16," ERREUR !" Calcul_Age = 0
Exit Function
End Function