تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
طريقة معرفة عمر الموظف ........ بالسنوات
#3
السلام عليكم و رحمة الله و بركاته
بالاضافة لما قدمه الاخ عبد العزيز البسكري,
دالة تقوم بحساب العمر (سنة و شهر) و تضعه في Dictionary و انت ستدعي ما تريده منها.
PHP كود :
   'دالة لحساب العمر
    Function CalcAge(ByVal vDate1 As Date, ByVal vdate2 As Date) As Dictionary(Of Integer, Integer)
        Dim AgeCAlc As New Dictionary(Of Integer, Integer)

        Dim vYears As Integer, vMonths As Integer, vDays As Integer

        vMonths = DateDiff("m", vDate1, vdate2)

        vDays = DateDiff("d", DateAdd("m", vMonths, vDate1), vdate2)

        If vDays < 0 Then

            vMonths = vMonths - 1

            vDays = DateDiff("d", DateAdd("m", vMonths, vDate1), vdate2)

        End If

        vYears = vMonths \ 12

        vMonths = vMonths Mod 12

        AgeCAlc.Add(vYears, vMonths)
        Return AgeCAlc
     
    End Function 

طريقة الاستدعاء لما تريد , بفرض لديك DateTimePiker و اسمها Dt_Brithdate
كما يلي:
PHP كود :
  

        If Dt_Brithdate
.DateTime DateTime.Now Then

            
'لحساب السنة
            Txt_Ageyear.Text = CalcAge(Format(DateTime.Now, "dd/MM/yyyy"), Format(Dt_Brithdate.DateTime, "dd/MM/yyyy")).Keys.ElementAt(0)
            '
لحساب الشهر
            Txt_Agemonth
.Text CalcAge(Format(DateTime.Now"dd/MM/yyyy"), Format(Dt_Brithdate.DateTime"dd/MM/yyyy")).Values.ElementAt(0)

 
       Else

            Txt_Ageyear
.Text CalcAge(Dt_Brithdate.DateTimeDateTime.Now).Keys.ElementAt(0)
 
           Txt_Agemonth.Text CalcAge(Dt_Brithdate.DateTimeDateTime.Now).Values.ElementAt(0)

 
       End If
 
       If Dt_Brithdate.DateTime Nothing Then
            Txt_Ageyear
.Text 0
            Txt_Agemonth
.Text 0
        End 
If 
اللهم لك الحمد كما ينبغي لجلال وجهك و عظيم سلطانك
في حل و ترحال
الرد }}}
تم الشكر بواسطة: عبد العزيز البسكري , sendbad100


الردود في هذا الموضوع
RE: طريقة معرفة عمر الموظف ........ بالسنوات - بواسطة ابو ليلى - 09-05-18, 11:13 PM


التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم