الإخوة الأفاضل
هذه الدالة كانت في برنامج تحديد سن التقاعد للموظفين من تصميم الأخت /زهرة
فهل أجد من يشرحها لي
لكم خالص الشكر سلفاً
Public Function EndWork(ByVal DateFm As Variant, ByVal DateTo As Variant, DGP As Integer, MGP As Integer, YGP As Integer) Dim ddf As Byte, mmf As Byte, yyf As Integer Dim ddt As Byte, mmt As Byte, yyt As Integer DGP = 0: MGP = 0: YGP = 0 Select Case VarType(DateFm) Case vbDate, vbLong DateFm = DateFm - 1 DateFm = Format(DateFm, "dd/mm/yyyy") DateTo = Format(DateTo, "dd/mm/yyyy") Case vbString If DateFm Like "##[-/]##[-/]####" Then DateFm = Format(Val(Left(DateFm, 2)) - 1, "00") & Mid(DateFm, 3) ElseIf DateFm Like "####[-/]##[-/]##" Then DateFm = Format(Val(Right(DateFm, 2)) - 1, "00") & "/" & _ Mid(DateFm, 6, 2) & "/" & Left(DateFm, 4) DateTo = Right(DateTo, 2) & "/" & Mid(DateTo, 6, 2) & "/" & Left(DateTo, 4) Else Exit Function End If Case Else Exit Function End Select '------------------ ddf = Mid(DateFm, 1, 2) mmf = Mid(DateFm, 4, 2) yyf = Mid(DateFm, 7, 4) ddt = Mid(DateTo, 1, 2) mmt = Mid(DateTo, 4, 2) yyt = Mid(DateTo, 7, 4) If ddt < ddf Then ddt = ddt + 30: mmt = mmt - 1 End If If mmt < mmf Then mmt = mmt + 12: yyt = yyt - 1 End If DGP = ddt - ddf MGP = mmt - mmf YGP = yyt - yyf End Function

