Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Wouter Benoit
Starting Member
23 Posts |
Posted - 2008-05-15 : 08:51:17
|
Hy,I'm making my first project in C# and I'm trying to do a check if at least one of the radiobuttons are checked when I press the button OK.So in the code for the OK button I do:if (rdbBeginner.Checked == false) && (rdbGevorderde.Checked == false) && (rdbExpert.Checked == false); { MessageBox.Show("Gelieve een keuze te maken op welk niveau u wenst te spelen.", MessageBoxIcon.Information); }else{...}But when I compile the code I get an error " Invalid Expression term '&&' !So I wonder what is wrong with the expression. I tried the same in vb.NET (but with And) and there it works just fine.Thanks in advance |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2008-05-15 : 08:55:32
|
There should not be a semi-colon on the line with the IF; also, the entire boolean expression should be in parenthesis.if ((rdbBeginner.Checked == false) && (rdbGevorderde.Checked == false) && (rdbExpert.Checked == false)) // notice there is no semi colon here{MessageBox.Show("Gelieve een keuze te maken op welk niveau u wenst te spelen.", MessageBoxIcon.Information);}else{...}You can also write your condition shorter if you think it will be more readable by using the NOT operator (!) :if (!rdbBeginner.Checked && !rdbGevorderde.Checked && !rdbExpert.Checked).... etc ...- Jeffhttp://weblogs.sqlteam.com/JeffS |
|
|
Wouter Benoit
Starting Member
23 Posts |
Posted - 2008-05-15 : 08:57:55
|
Never mind, I just found outThanks for the help anyway |
|
|
|
|
|