我正在为我的学校课程构建一个计算项目,并且我有一个相当大的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