تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
update العمر
#3
تفضل أخي عبدالعزيز
كود :
Public Class Form1

   Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
       Me.DateTimePicker1.Value = GetSetting(Application.ProductName, "Age", "Birthday", Now)
       DateTimePicker1_KeyUp(Nothing, Nothing)
   End Sub
   Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
       SaveSetting(Application.ProductName, "Age", "Birthday", Me.DateTimePicker1.Value.Date)
   End Sub

   Private Sub DateTimePicker1_KeyUp(sender As Object, e As KeyEventArgs) Handles DateTimePicker1.KeyUp
       Dim dob As DateTime
       dob = New DateTime(DateTimePicker1.Value.Year, DateTimePicker1.Value.Month, DateTimePicker1.Value.Day)
       Dim tday As TimeSpan = DateTime.Now.Subtract(dob)
       Dim years As Integer, months As Integer, days As Integer
       months = 12 * (DateTime.Now.Year - dob.Year) + (DateTime.Now.Month - dob.Month)
       If DateTime.Now.Day < dob.Day Then
           months -= 1
           days = DateTime.DaysInMonth(dob.Year, dob.Month) - dob.Day + DateTime.Now.Day
       Else
           days = DateTime.Now.Day - dob.Day
       End If
       years = Math.Floor(months / 12)
       months -= years * 12
       TextBox1.Text = years : TextBox2.Text = months : TextBox3.Text = days
   End Sub

End Class
الرد }}}
تم الشكر بواسطة: elgokr , حافظ حافظ , muaamar


الردود في هذا الموضوع
update العمر - بواسطة حافظ حافظ - 23-09-18, 10:31 PM
RE: update العمر - بواسطة elgokr - 23-09-18, 10:46 PM
RE: update العمر - بواسطة 911 - 23-09-18, 11:12 PM
RE: update العمر - بواسطة muaamar - 25-12-20, 09:07 PM


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


يقوم بقرائة الموضوع: