473,563 Members | 2,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Operator && Error

When running the following code:

if (typeCheck.Chec ked == true && typeList.Select edItem == "3")
{
return " and wopm3 = '3' or wopm3 = '3C' or wopm3 = '3I'";
}

I get the following error:

Operator '&&' cannot be applied to operands of type 'bool'

Hoiw can I alter my code to handle this error?

Thanks,

Dave
Nov 16 '05 #1
3 6977
Dave Bailey <an*******@disc ussions.microso ft.com> wrote:
When running the following code:

if (typeCheck.Chec ked == true && typeList.Select edItem == "3")
{
return " and wopm3 = '3' or wopm3 = '3C' or wopm3 = '3I'";
}

I get the following error:

Operator '&&' cannot be applied to operands of type 'bool'

Hoiw can I alter my code to handle this error?


Well, this simplest transformation of the above is:

if ((typeCheck.Che cked==true) && (typeList.Selec tedItem=="3"))

However, I would expect the above to compile okay, to be honest. Could
you post a short but complete program which demonstrates the problem?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Hi Dave,
I assumed that typeCheck is a checkbox & typeList is a DropDownList/ComboBox
or Listbox
If so I got a warning saying that "Possible unintended reference
comparison; to get a value comparison, cast the left hand side to type
'string'" refering to the comparision between a object ( SelectedItem ) and
a string.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Dave Bailey" <an*******@disc ussions.microso ft.com> wrote in message
news:BC******** *************** ***********@mic rosoft.com...
When running the following code:

if (typeCheck.Chec ked == true && typeList.Select edItem == "3")
{
return " and wopm3 = '3' or wopm3 = '3C' or wopm3 = '3I'";
}

I get the following error:

Operator '&&' cannot be applied to operands of type 'bool'

Hoiw can I alter my code to handle this error?

Thanks,

Dave

Nov 16 '05 #3
Try
if ((typeCheck.Che cked == true) && (typeList.Selec tedItem == "3"))
{
return " and wopm3 = '3' or wopm3 = '3C' or wopm3 = '3I'";
}
if it is what you wanted

"Dave Bailey" <an*******@disc ussions.microso ft.com> wrote in message
news:BC******** *************** ***********@mic rosoft.com...
When running the following code:

if (typeCheck.Chec ked == true && typeList.Select edItem == "3")
{
return " and wopm3 = '3' or wopm3 = '3C' or wopm3 = '3I'";
}

I get the following error:

Operator '&&' cannot be applied to operands of type 'bool'

Hoiw can I alter my code to handle this error?

Thanks,

Dave

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2018
by: Zenon | last post by:
Folks, I have been trying for a week but I cannot debug the following error: Error E2285 ex5.cpp 141: Could not find a match for 'matrix<complex<double>>::operator =(complex<double>)' in function main() Here is the relevant portion of my template class //***************************************************************************
9
1697
by: Marchello | last post by:
Hi All. I will try to explain my question on following example: Having class CInteger (wraper on 'int' values): class CInteger { public: ..... void SetValueFromPoiner(int *new_value)
2
4575
by: David Laub | last post by:
I know there is no C# exponentiation operator. But since the double class is sealed, there seems no way to add the operator override without creating a new class which uses containment (of a double value) This seems a major pain, and would probably wind up being more syntactically messy than just calling Math.Pow(x,y) Surely greater...
1
1794
by: sd2004 | last post by:
Could someone please help ? I am getting compiling error but do not understand why ? below is snipset of code: istream& operator>>(istream& is, test_ins& s){ is >>s.pass>>s.put>>s.type; //line 22 is >>s.test_one>>s.test_two>>s.test_three; /line 23 is >>s.test_four >>s.test_five>>s.test_six; //line 24...
2
4443
by: linq936 | last post by:
Hi, I have this piece code, struct TriStr { MyString str1; MyString str2; MyString str3; TriStr(MyString s1, MyString s2, MyString s3){ this->str1 = s1;
6
2310
by: Angel Tsankov | last post by:
How can an overloaded operator& take the address of its argument: template<typename T> Smth operator &(T& SomeObject) { // The address of SomeObject is needed here }
39
4692
by: dancer | last post by:
Can somebody tell me why I get this message with the following code? Compiler Error Message: BC30452: Operator '&' is not defined for types 'String' and 'System.Web.UI.WebControls.TextBox'. <html> <head> <% @Import Namespace="System.Web.Mail" %>
0
7664
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7638
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.