dimanche 13 mars 2016

Visual Basic If statements with Check Boxes

I'm doing a homework assignment for a class of mine. The basis is there are 3 radio button options, and 6 check boxes. Any number of check boxes can be checked for each radio button and I'm making if statements for every single possibility. I'm not sure if that is the right way to be going about this because it is so much more code than anything else we've been doing lately.

If ckboxPlatter.Checked = True And ckboxServing.Checked = True And ckboxSoup.Checked = True And ckboxSugar.Checked = True And ckboxCreamer.Checked = True And ckboxTeapot.Checked = True Then
                    lblOrder.Text = "Thank you for your order!" &
            ControlChars.NewLine & "You Ordered:" &
            ControlChars.NewLine & "1 place setting of Blue Willow" &
            ControlChars.NewLine & "Platter" &
            ControlChars.NewLine & "Serving Bowl" &
            ControlChars.NewLine & "8 Soup Bowls" &
            ControlChars.NewLine & "Sugar Bowl" &
            ControlChars.NewLine & "Creamer" &
            ControlChars.NewLine & "Teapot" &
            ControlChars.NewLine & "For a grand total of $" & (dblWessex + dblPlatter + dblServing + dblSoup + dblSugar + dblCreamer + dblTeapot)

And I would have to do that for every single possibility with the checkboxes, and also do that for each radio button. On top of that there is a listbox to go along with it with 20 indexes. Is there another way to do this that isn't as long?




Aucun commentaire:

Enregistrer un commentaire