Check boxes in visual basic (quick question)

GoldenI

Distinguished
Nov 11, 2010
37
0
18,580
0
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
3
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;
}
 
Thread starter Similar threads Forum Replies Date
M Apps General Discussion 2
F Apps General Discussion 7
V Apps General Discussion 1
F Apps General Discussion 1
C Apps General Discussion 2
P Apps General Discussion 5
tarmiricmi Apps General Discussion 15
noyaus Apps General Discussion 2
G Apps General Discussion 0
jpe1701 Apps General Discussion 21
NewsFromHell Apps General Discussion 2
L Apps General Discussion 1
G Apps General Discussion 1
G Apps General Discussion 0
J Apps General Discussion 1
Lutfij Apps General Discussion 0
M Apps General Discussion 4
D Apps General Discussion 2
I Apps General Discussion 1
S Apps General Discussion 1

ASK THE COMMUNITY