学校の授業でコンピューティング プロジェクトを作成していて、かなり大きなif
ステートメントがあります。if
プログラムを実行すると、まったく遅くはありませんが、大きなステートメントを書くのは悪いと考えられているのではないかと思っていました.
For BookingNumber = 0 To intBookingCount - 1
If intStartPeriod(BookingNumber) = 1 And strComputerRoom(BookingNumber) = strCR Then
radRadioButton1.Enabled = False
If intLength(BookingNumber) = 1 Then
ElseIf intLength(BookingNumber) = 2 Then
radRadioButton2.Enabled = False
ElseIf intLength(BookingNumber) = 3 Then
radRadioButton2.Enabled = False
radRadioButton3.Enabled = False
ElseIf intLength(BookingNumber) = 4 Then
radRadioButton2.Enabled = False
radRadioButton3.Enabled = False
radRadioButton4.Enabled = False
ElseIf intLength(BookingNumber) = 5 Then
radRadioButton2.Enabled = False
radRadioButton3.Enabled = False
radRadioButton4.Enabled = False
radRadioButton5.Enabled = False
ElseIf intLength(BookingNumber) = 6 Then
radRadioButton2.Enabled = False
radRadioButton3.Enabled = False
radRadioButton4.Enabled = False
radRadioButton5.Enabled = False
radRadioButton6.Enabled = False
ElseIf intLength(BookingNumber) = 7 Then
radRadioButton2.Enabled = False
radRadioButton3.Enabled = False
radRadioButton4.Enabled = False
radRadioButton5.Enabled = False
radRadioButton6.Enabled = False
radRadioButton7.Enabled = False
End If
ElseIf intStartPeriod(BookingNumber) = 2 And strComputerRoom(BookingNumber) = strCR Then
radRadioButton2.Enabled = False
If intLength(BookingNumber) = 2 Then
radRadioButton3.Enabled = False
ElseIf intLength(BookingNumber) = 3 Then
radRadioButton3.Enabled = False
radRadioButton4.Enabled = False
ElseIf intLength(BookingNumber) = 4 Then
radRadioButton3.Enabled = False
radRadioButton4.Enabled = False
radRadioButton5.Enabled = False
ElseIf intLength(BookingNumber) = 5 Then
radRadioButton3.Enabled = False
radRadioButton4.Enabled = False
radRadioButton5.Enabled = False
radRadioButton6.Enabled = False
ElseIf intLength(BookingNumber) = 6 Then
radRadioButton3.Enabled = False
radRadioButton4.Enabled = False
radRadioButton5.Enabled = False
radRadioButton6.Enabled = False
radRadioButton7.Enabled = False
End If
ElseIf intStartPeriod(BookingNumber) = 3 And strComputerRoom(BookingNumber) = strCR Then
radRadioButton3.Enabled = False
If intLength(BookingNumber) = 2 Then
radRadioButton4.Enabled = False
ElseIf intLength(BookingNumber) = 3 Then
radRadioButton4.Enabled = False
radRadioButton5.Enabled = False
ElseIf intLength(BookingNumber) = 4 Then
radRadioButton4.Enabled = False
radRadioButton5.Enabled = False
radRadioButton6.Enabled = False
ElseIf intLength(BookingNumber) = 5 Then
radRadioButton4.Enabled = False
radRadioButton5.Enabled = False
radRadioButton6.Enabled = False
radRadioButton7.Enabled = False
End If
ElseIf intStartPeriod(BookingNumber) = 4 And strComputerRoom(BookingNumber) = strCR Then
radRadioButton4.Enabled = False
If intLength(BookingNumber) = 2 Then
radRadioButton5.Enabled = False
ElseIf intLength(BookingNumber) = 3 Then
radRadioButton5.Enabled = False
radRadioButton6.Enabled = False
ElseIf intLength(BookingNumber) = 4 Then
radRadioButton5.Enabled = False
radRadioButton6.Enabled = False
radRadioButton7.Enabled = False
End If
ElseIf intStartPeriod(BookingNumber) = 5 And strComputerRoom(BookingNumber) = strCR Then
radRadioButton5.Enabled = False
If intLength(BookingNumber) = 2 Then
radRadioButton6.Enabled = False
ElseIf intLength(BookingNumber) = 3 Then
radRadioButton6.Enabled = False
radRadioButton7.Enabled = False
End If
ElseIf intStartPeriod(BookingNumber) = 6 And strComputerRoom(BookingNumber) = strCR Then
radRadioButton6.Enabled = False
If intLength(BookingNumber) = 2 Then
radRadioButton7.Enabled = False
End If
ElseIf intStartPeriod(BookingNumber) = 7 And strComputerRoom(BookingNumber) = strCR Then
radRadioButton7.Enabled = False
End If
Next
Next
End Function