Check boxes in visual basic (quick question)

GoldenI

Distinguished
Nov 11, 2010
37
0
18,580
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!

 

theDanijel

Distinguished
May 4, 2011
74
0
18,590
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;
}