How to return separate text box value to display independently in result label?

  • Thread starter Thread starter MoistCode
  • Start date Start date
M

MoistCode

Guest
Hi,


I am working on coding a small project for my school and I have the first text box to display the first algorithm value but we also have to make a second algorithm to calculate the most popular survey out of 100 people. I got the code down but due to the line of code that the program runs whenever I put a number in the first algorithm textbox it would results in the last code even tho I already declared a variable and which textbox it's for already it would result in saying "no" when I want it to display the correct "most popular result."

Here are my code: (again I want to separate the first algorithm textbox and the second algorithm textbox so it would still function well under one calculate button)


private void btnCheck_Click(object sender, EventArgs e)
{

// Declare variable and assign values
int intAlgorithmOne;
int intAlgorithmTwo;
int intAlgorithmTwoTwo;

int.TryParse(txtAlOne.Text, out intAlgorithmOne);
int.TryParse(txtFirstSet.Text, out intAlgorithmTwo);
int.TryParse(txtSecondSet.Text, out intAlgorithmTwoTwo);

// If-else statement of all values
// Data entered will give results to user



if (intAlgorithmTwo < 38 == intAlgorithmTwoTwo < 38)
{
lblGivenResult.Text = "no/ not sure";


if (intAlgorithmOne <= 49)
{
lblGivenResult.Text = "no";
txtAlOne.SelectAll();

if (intAlgorithmOne >= 50)
{

lblGivenResult.Text = "This is the most popular answer";
txtAlOne.Focus();
txtAlOne.SelectAll();

if (intAlgorithmOne >= 101)
{
lblGivenResult.Text = "There is no more than 100 survey";
}
}

}

if (intAlgorithmTwo <= 33 == intAlgorithmTwoTwo <=33)
{
lblGivenResult.Text = "No";

}
if (intAlgorithmTwo > 33 == intAlgorithmTwoTwo < 33)
{
lblGivenResult.Text = "Yes this is the most popular" + intAlgorithmTwo.ToString();
}
}



else
{
lblGivenResult.Text = "Please input correct poll number";

}





}

Continue reading...
 
Back
Top