Check boxes in visual basic (quick question)

How do I add values of check boxes together when calculating them? For example, if I have a checkbox labeled hairstyle and the value of that is $125, and another check box is labeled "Makeup" with a price of $300, how would I be able to add those two together when I calculate them? I have four check boxes.

Hairstyle = $125
Makeup = $300
Makeover = $400
Manicure = $35

How would I set my coding to add ANY of those together when they're clicked? What if Hairstyle is clicked, and then Manicure? I am writing this for school and am stuck.

Please help!
3 answers Last reply
More about check boxes visual basic quick question
  1. So the label is "Hairstyle = $125" or do you have textbox's containing the values?
  2. Add the same event handeler to every check box and set them to call the same method. So each time you check or uncheck it will calculate. The code would look something like this (C#, I don't know the excact syntax of VB):

    public int price (){
    int sum=0;
    if(Hairstyle.isChecked) sum+=125;
    if(Makeup.isChecked) sum+=300;
    if(Makeover.isChecked) sum+=400;
    if(Manicure.isChecked) sum+=35;
    return sum;
    }
  3. I agree with the above, but the return value should be a real type, not an integer. An integer would work in this example, but in the real world nothing is an even dollar value.
Ask a new question

Read More

Programming Visual Basic Apps