我为学校的分数计算编写代码。当学生总得分低于68时,他们将有机会获得奖励分数。奖励分数有三个选项可供选择。但是,当加入奖金时,总分不能超过68分。我该怎么做最后一部分?
这是我写的代码
If result < 68 Then
If RadioButton1.Checked = True Then
bonus = 15.0
End If
If RadioButton2.Checked = True Then
bonus = 10.0
End If
If RadioButton3.Checked = True Then
bonus = 5.0
End If
End If
total = result + bonus
Dim IsBonusAdded As Boolean
IsBonusAdded = False
If result < 68 Then
If RadioButton1.Checked = True Then
bonus = bonus
IsBonusAdded = True
End If
If RadioButton2.Checked = True Then
bonus = 10.0
IsBonusAdded = True
End If
If RadioButton3.Checked = True Then
bonus = 5.0
IsBonusAdded = True
End If
End If
total = result + bonus
' total can't be more than 68 if bonus added
If IsBonusAdded And total >=68 Then
total = 68
End If
Dim IsBonusAdded As Boolean
If result < 68 Then
If RadioButton1.Checked = True Then
bonus = bonus + 15
IsBonusAdded = True
End If
If RadioButton2.Checked = True Then
bonus = bonus + 10
IsBonusAdded = True
End If
If RadioButton3.Checked = True Then
bonus = bonus + 5
IsBonusAdded = True
End If
End If
total = result + bonus
' total can't be more than 68 if bonus added
If IsBonusAdded And total >68 Then
total = 68
End If