28-10-16, 10:33 PM
اولاالداله اللي بستخدمها لحساب تاريخ الميلاد
Dim alldays As Integer = (Val(Txtyear.Text) * 365.25) + (Val(Txtmonth.Text) * 30.6375) + Val(Txtday.Text)
Dim DOB As Date = (DateAdd(DateInterval.Day, (-alldays), Now))
ثانيا الدالة المستخدمة للاسترجاع
Public Shared Function GetDateSpanText(fromDate As DateTime, Optional toDate As DateTime = Nothing) As String
Try
Dim years As Integer = 0, months As Integer = 0, days As Integer = 0
If toDate = Nothing Then toDate = DateTime.Now
Do Until toDate.AddYears(-1) < fromDate
years += 1
toDate = toDate.AddYears(-1)
Loop
Do Until toDate.AddMonths(-1) < fromDate
months += 1
toDate = toDate.AddMonths(-1)
Loop
Do Until toDate.AddDays(-1) < fromDate
days += 1
toDate = toDate.AddDays(-1)
Loop
' Return String.Format("{0} Years {1} Months {2} Days", years, months, days)
Return years & "|" & months & "|" & days
Catch ex As Exception
Return "Error"
End Try
End Function
Dim alldays As Integer = (Val(Txtyear.Text) * 365.25) + (Val(Txtmonth.Text) * 30.6375) + Val(Txtday.Text)
Dim DOB As Date = (DateAdd(DateInterval.Day, (-alldays), Now))
ثانيا الدالة المستخدمة للاسترجاع
Public Shared Function GetDateSpanText(fromDate As DateTime, Optional toDate As DateTime = Nothing) As String
Try
Dim years As Integer = 0, months As Integer = 0, days As Integer = 0
If toDate = Nothing Then toDate = DateTime.Now
Do Until toDate.AddYears(-1) < fromDate
years += 1
toDate = toDate.AddYears(-1)
Loop
Do Until toDate.AddMonths(-1) < fromDate
months += 1
toDate = toDate.AddMonths(-1)
Loop
Do Until toDate.AddDays(-1) < fromDate
days += 1
toDate = toDate.AddDays(-1)
Loop
' Return String.Format("{0} Years {1} Months {2} Days", years, months, days)
Return years & "|" & months & "|" & days
Catch ex As Exception
Return "Error"
End Try
End Function

