تأييداً لكلام الأستاذ @kkhalifa1960 ،
أرجو تجربة التعديل بهذا الكود ،
Private Sub Calc_Click()
نص3 = DateAdd("d", DateDiff("d", [بداية العمل], [نهاية العمل]) / 2, [بداية العمل])
Dim startDate As Date
Dim endDate As Date
Dim years As Integer
Dim months As Integer
Dim days As Integer
startDate = [بداية العمل]
endDate = [نهاية العمل]
years = DateDiff("yyyy", startDate, endDate)
months = DateDiff("m", DateAdd("yyyy", years, startDate), endDate)
days = DateDiff("d", DateAdd("m", months, DateAdd("yyyy", years, startDate)), endDate)
If Day(endDate) < Day(startDate) Then
months = months - 1
days = DateDiff("d", DateAdd("m", months, DateAdd("yyyy", years, startDate)), endDate)
End If
If Month(endDate) < Month(startDate) Then
months = 12 + Month(endDate) - Month(startDate)
End If
If Day(startDate) = Day(endDate) + 1 Then
days = 0
End If
Dim result As String
result = years & " سنة " & months & " شهر " & days & " يوم"
نص5 = result
نص10 = days
نص12 = months
نص14 = years
End Sub