1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
| PUBLIC SUB CmdCalDe_Click() '<------------------------------------------------ 'différences entre deux dates
DIM dateDepart, dateArrive AS DATE DIM iJour, iAn, iTrim, iWeek, iHeure, iMinute, iMois, iSeconde AS INTEGER DIM sDonc1, sDonc2, sTruc1, sTruc2 AS STRING
'------------------------------------------------------------------------------------------- sDonc1 = sTrans1 '<--------------------------------------------------------- variable de transposition IF sDonc1 = "" THEN sDonc1 = "01/01/0000" sTruc1 = Mid(sDonc1, 4, 2) & "/" & Mid(sDonc1, 1, 2) & "/" & Mid(sDonc1, 7, 4) '<-- retourne le format US
IF IsDate(sDonc1) = FALSE THEN RETURN '<----------------------------------- il faut une date dateDepart = Date(CDate(sTruc1)) '<----------------------------------- au format US lblDepart.Text = sDonc1 '<----------------------------------------------- au format FR ' vbxDebut.Text = sDonc1 ' lblDepart.Text = Format(DateDepart, "dd/mm/yyyy") '------------------------------------------------------------------------------------------- sDonc2 = sTrans2 '<--------------------------------------------------------- variable de transposition IF sDonc2 = "" THEN sDonc2 = Format(Date(Now), "dd/mm/yyyy") sTruc2 = Mid(sDonc2, 4, 2) & "/" & Mid(sDonc2, 1, 2) & "/" & Mid(sDonc2, 7, 4) '<-- retourne le format US
IF IsDate(sDonc2) = FALSE THEN RETURN '<----------------------------------- il faut une date dateArrive = Date(CDate(sTruc2)) '<---------------------------------- au format US lblDarrive.Text = sDonc2 '<----------------------------------------------- au format FR ' vbxFin.Text = sDonc2 ' lblDarrive.Text = Format(DateArrive, "dd/mm/yyyy")
lblDepVal.Text = Format(CFloat(dateDepart), "#,###.###") '<--------------------- affichage valeur entière de la date (dateDepart) lblDaVal.Text = Format(CFloat(dateArrive), "#,###.###") lblDifff.Text = Format(CFloat(dateArrive) - CFloat(dateDepart), "#,###.###")
iJour = DateDiff(dateDepart, dateArrive, gb.Day) iAn = DateDiff(dateDepart, dateArrive, gb.Year) iTrim = DateDiff(dateDepart, dateArrive, gb.Quarter) iWeek = DateDiff(dateDepart, dateArrive, gb.Week) iHeure = DateDiff(dateDepart, dateArrive, gb.Hour) iMois = DateDiff(dateDepart, dateArrive, gb.Month)
IF Abs(iJour) < 2 THEN lblDif.Text = Format(Abs(iJour), "#,###") & " jour" ELSE lblDif.Text = Format(Abs(iJour), "#,###") & " jours" ENDIF
IF Abs(iAn) < 2 THEN lblDif2.Text = Format(Abs(iAn), "#,###") & " an" ELSE lblDif2.Text = Format(Abs(iAn), "#,###") & " ans" ENDIF
IF Abs(iTrim) < 2 THEN lblDif3.Text = Format(Abs(iTrim), "#,###") & " trimestre" ELSE lblDif3.Text = Format(Abs(iTrim), "#,###") & " trimestres" ENDIF
IF Abs(iWeek) < 2 THEN lblDif5.Text = Format(Abs(iWeek), "#,###") & " semaine" ELSE lblDif5.Text = Format(Abs(iWeek), "#,###") & " semaines" ENDIF
IF Abs(iHeure) < 2 THEN lblDif6.Text = Format(Abs(iHeure), "#,###") & " heure" ELSE lblDif6.Text = Format(Abs(iHeure), "#,###") & " heures" ENDIF
lblDif7.Text = Format(Abs(iMois), "#,###") & " mois"
TRY iMinute = DateDiff(dateDepart, dateArrive, gb.Minute) '<------------- error OverFlow IF ERROR THEN lblDif8.Foreground = Color.Red lblDif8.Text = sAlerte & "en minutes" ELSE IF Abs(iMinute) < 2 THEN lblDif8.Text = Format(Abs(iMinute), "#,###") & " minute" ELSE lblDif8.Text = Format(Abs(iMinute), "#,###") & " minutes" ENDIF ENDIF
TRY iSeconde = DateDiff(dateDepart, dateArrive, gb.Second) '<------------ error OverFlow IF ERROR THEN lblDif9.Foreground = Color.Red lblDif9.Text = sAlerte & "en secondes" RETURN ELSE IF Abs(iSeconde) < 2 THEN lblDif9.Text = Format(Abs(iSeconde), "#,###") & " seconde" ELSE lblDif9.Text = Format(Abs(iSeconde), "#,###") & " secondes" ENDIF ENDIF
CATCH Message.Info("Une ERREUR de saisie ! ")
END
|