هذا البرنامج لحساب عدد الفصول بين تاريخين ، حيث في كل سنة هناك اربعة فصول وهي : 1-3 و 4-6 و 7-9 ومن 10-12
لا ادري اين الخل في هذا الكود فهو لا يعيد قيم ال X او ال y كما يجب اي حسب جملة CASE المبنية :
Dim FD, ED As Date
FD = CType(FirstDate.Text.ToString, Date)
ED = CType(EndDate.Text.ToString, Date)
'Response.Write("The Year" & Year(FD) & " The Month " & CType(Month(FD).GetTypeCode.Int32, String) & "the add 3 :")
'Dim RD As Date = FD.AddMonths(3)
'Response.Write(RD.ToString)
' لحساب عدد الميزانيات الفرعية
Dim x, y As Int32
'Dim NumberOfQuarter As Int32
Dim NumberOfYear As Int32 = Year(ED) - Year(FD)
If NumberOfYear = 0 Then
Select Case Month(FD)
Case Is >= 1 <= 3
x = 4
Case Is >= 4 <= 6
x = 3
Case Is >= 7 <= 9
x = 2
Case Is >= 10 <= 12
x = 1
End Select
NumberOfQuarter = x
ElseIf (NumberOfYear <> 0) Then
Dim fdC As Int32 = Month(FD)
Select Case fdC
Case Is >= 1 <= 3
x = 4
Case Is >= 4 <= 6
x = 3
Case Is >= 7 <= 9
x = 2
Case Is >= 10 <= 12
x = 1
End Select
Dim edC As Int32 = Month(ED)
Select Case edC
Case Is >= 1 <= 3
y = 1
Case Is >= 4 <= 6
y = 2
Case Is >= 7 <= 9
y = 3
Case Is >= 10 <= 12
y = 4
End Select
NumberOfQuarter = (4 * (NumberOfYear - 1)) + x + y
End If
Response.Write("the number = " & NumberOfQuarter & " x is = " & x & " Y = " & y)
طبعا بإمكاني عمل ذلك بجملة IF Else متداخلة
ولكن هذا ليس فكر برمجي !
