i.lover3000
شنبه 16 مهر 1390, 19:24 عصر
سلام و خسته نباشید
چطوری میشه مثلا بفهمین 20 روز پیش چندم بوده؟ آیا خود ویژوال استادیو همچین قابلیتی داره یا خودمون باید
واسش بنویسیم ؟؟
من یه فانکشن نوشتم ولی مشکل داره و درست کار نمیکنه. هنوز کار داره و فکر کنم باید از یه حلقه یا تابع بازگشتی استفاده بشه. لطفا راهنمایی کنید.
Public Function MonagheseDate(ByVal DayAGo As Byte) As Date
Dim nDay, nMonth, nYear, tDay As Integer
nDay = Now.Day
nMonth = Now.Month
nYear = Now.Year
If nDay - DayAGo >= 1 Then
nDay = nDay - DayAGo
Else
tDay = DayAGo - nDay
If nMonth - 1 >= 1 Then
nMonth -= 1
Else
nYear -= 1
nMonth = 1
End If
Select Case nMonth
Case 1, 3, 5, 7, 8, 10, 12
If 31 - tDay > 0 Then
nDay = 31 - tDay
Else
End If
Case 4, 6, 9, 11
If 30 - tDay > 0 Then
nDay = 30 - tDay
End If
Case 2
If 28 - tDay > 0 Then
nDay = 28 - tDay
End If
End Select
End If
Dim nDate As New Date(nYear, nMonth, nDay)
Return nDate
End Function
چطوری میشه مثلا بفهمین 20 روز پیش چندم بوده؟ آیا خود ویژوال استادیو همچین قابلیتی داره یا خودمون باید
واسش بنویسیم ؟؟
من یه فانکشن نوشتم ولی مشکل داره و درست کار نمیکنه. هنوز کار داره و فکر کنم باید از یه حلقه یا تابع بازگشتی استفاده بشه. لطفا راهنمایی کنید.
Public Function MonagheseDate(ByVal DayAGo As Byte) As Date
Dim nDay, nMonth, nYear, tDay As Integer
nDay = Now.Day
nMonth = Now.Month
nYear = Now.Year
If nDay - DayAGo >= 1 Then
nDay = nDay - DayAGo
Else
tDay = DayAGo - nDay
If nMonth - 1 >= 1 Then
nMonth -= 1
Else
nYear -= 1
nMonth = 1
End If
Select Case nMonth
Case 1, 3, 5, 7, 8, 10, 12
If 31 - tDay > 0 Then
nDay = 31 - tDay
Else
End If
Case 4, 6, 9, 11
If 30 - tDay > 0 Then
nDay = 30 - tDay
End If
Case 2
If 28 - tDay > 0 Then
nDay = 28 - tDay
End If
End Select
End If
Dim nDate As New Date(nYear, nMonth, nDay)
Return nDate
End Function