0

I have assigned the value whether the check box is ticked or not to a vairable.I want to pass the value to a function.

how do I do that ?

if (checkbox1.checked==true)
{
value1 = "I am here"
}
if (checkbox2.checked==true)
{
value2="I am there"
}

value3 = value1 + value2


function (value3)
{
.....
}

thee b problem is value 1 and value 2 are out of scope for value 3 ?what should I do ?

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by praveendasika
1

Declare the variables value1 and value2 before the if-statements.

int value1 = 0;
int value2 = 0;
if (checkbox1.checked) // you don't need to say == true here
  value1 = 1000000;
if (checkbox2.checked)
  value2 = -392014;
int value3 = value1 + value2;
myFunction(value3);

//...

public void myFunction(int value3)
{
  // do something...
}

PS please use code tags, it makes posts much easier to read.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.