1 Replies - 5924 Views - Last Post: 05 February 2009 - 09:28 PM Rate Topic: -----

#1 RachieL312  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-February 09

Combo Box and If Else Statement

Post icon  Posted 05 February 2009 - 09:01 PM

I'm very new to C# and I think this is a simple problem to fix, but I can't seem to find the exact information on it. I have a combo box with a few choices in it and based on the choice I want to execute a different equation. For example if you chose conjunction I want to perform an execution with and, if you chose disjunction I want to perform an execution with or. I think that a simple if else statement list or using a switch case would work well for this but I can't seem to get it to work. Any suggestions? Here's part of my code to give you an idea of what I'm working with...
			string Operation;
			Pbool = Convert.ToBoolean(P);
			Qbool = Convert.ToBoolean(Q);
			Operation = ComboBoxO.SelectedText;

			switch (Operation)
			{
				case "Conjunction":
					ResultsTextBox.Text = (Pbool && Qbool).ToString();
					break;
				case "Disjunction":
					ResultsTextBox.Text = (Pbool || Qbool).ToString();
					break;
			}


Is This A Good Question/Topic? 0
  • +

Replies To: Combo Box and If Else Statement

#2 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 774
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: Combo Box and If Else Statement

Posted 05 February 2009 - 09:28 PM

Are you getting any errors? First of all, where P and Q are declared? Second, try replacing SelectedText with Text for the Operation string.
Was This Post Helpful? 1

Page 1 of 1