We have a series of 10 check boxes. We are attempting to get a message to display depending on the series of check boxes selected. However, our problem is that upon pressing the button it shows all of the possible combinations.
Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If CheckBox1.Checked = True And CheckBox6.Checked = True Then MessageBox.Show("On Campus Student Center")
If CheckBox1.Checked = True And CheckBox7.Checked = True Then MessageBox.Show("On Campus Marketplace")
If CheckBox1.Checked = True And CheckBox8.Checked = True Then MessageBox.Show("Around Campus")
If CheckBox2.Checked = True And CheckBox3.Checked = True And CheckBox9.Checked = True Then MessageBox.Show("2 Mile Restaurant")
If CheckBox2.Checked = True And CheckBox3.Checked = True And CheckBox10.Checked = True Then MessageBox.Show("2 Mile FF")
If CheckBox2.Checked = True And CheckBox4.Checked = True And CheckBox9.Checked = True Then MessageBox.Show("3 Mile Restaurant")
If CheckBox2.Checked = True And CheckBox4.Checked = True And CheckBox10.Checked = True Then MessageBox.Show("3 Mile FF")
If CheckBox2.Checked = True And CheckBox5.Checked = True And CheckBox9.Checked = True Then MessageBox.Show("4 Mile Restaurant")
If CheckBox2.Checked = True And CheckBox5.Checked = True And CheckBox10.Checked = True Then MessageBox.Show("4 Mile FF")
If CheckBox1.Checked = True And CheckBox6.Checked = True And CheckBox7.Checked = True And CheckBox8.Checked = True Then MessageBox.Show("All On Campus")
If CheckBox1.Checked = True And CheckBox6.Checked = True And CheckBox7.Checked = True Then MessageBox.Show("Student Center and Marketplace")
If CheckBox1.Checked = True And CheckBox6.Checked = True And CheckBox8.Checked = True Then MessageBox.Show("Student Center and Around Campus")
If CheckBox1.Checked = True And CheckBox8.Checked = True And CheckBox7.Checked = True Then MessageBox.Show("Market Place and around")
End Sub
End Class
For example if we follow the checkbox selection of the last statement. Check boxes 1,7, and 8. We get the following message boxes, "On Campus Market Place", "Around Campus", and "Marketplace and around". Where as we only want it to show text for the final if statement.
Aucun commentaire:
Enregistrer un commentaire