I am new to vb.net and I have looked at other topics. I cannot find the answer I need. OK I have a combobox named cboRaceDesc and five checkboxes (CkRaceAfricanAmerican, ChkRaceAmerican Indian, ckRaceAsian, ckRacePacificIslander, and ckRaceWhite). I was going to post an image, but I cannot.
cboRaceDesc has two options...Hispanic and Other. If the user selects Other then they have to choose one of the five checkboxes or it will raise an exception when开发者_运维技巧 the record is being saved. I am assuming I would generate the code under the "save" button. I know I need to gather the following information in my code:
If cboRaceDesc.SelectedValue = Other Then
<I am not sure how to code the logic regarding the checkboxes>
<I know I need to use multiple else/else if statements>
<I know towards the end I would generate the exception>
End
Can anyone help me fill in the blanks or point me in the right direction? Thank you in advance.
If only one of 5 options can be selected then you should probably use radiobutton (with same group name) or radiobuttonlist control. Quick (and dirty) verification logic would be something like this:
If cboRaceDesc.SelectedValue = "Other" Then
if (CkRaceAfricanAmerican.Checked orelse
ChkRaceAmericanIndian.Checked orelse
ckRaceAsian.Checked orelse
ckRacePacificIslander.Checked orelse
ckRaceWhite.Checked) then
' show error message or throw exception
End if
End if
' save stuff
精彩评论