473,795 Members | 2,967 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with logical operator

Hi, I'm getting the following error message when I compile my program. I
tried different things but it's not working. Can someone help me look at
this and tell me what I've done wrong? Many thanks in adavnace.
error:
C:\Progs\ARComm and2003\Invoice PrePrintedContr act\frmPreview. cs(387):
Operator '||' cannot be applied to operands of type 'bool' and 'string'

source = m_dsLocal.Table s["Source"].Rows[0]["Source"].ToString();
SourcePrefix = source.Substrin g(0,2); // Prefix of pay sources

string PrivateInvoiceA llowBillInsuran ce, PrivateInvoiceA llowBillWorkCom p;

PrivateInvoiceA llowBillInsuran ce =
m_dsLocal.Table s["Global"].Rows[0]["PrivateInvoice AllowBillInsura nce"].ToString().Tri m();
PrivateInvoiceA llowBillWorkCom p =
m_dsLocal.Table s["Global"].Rows[0]["PrivateInvoice AllowBillWorkCo mp"].ToString().Tri m();

if (((SourcePrefix == "10") || (SourcePrefix== "11")|| (SourcePrefix== "20")
|| (SourcePrefix== "30"))
||(((SourcePref ix == "50")||(SourceP refix = "60")) &&
(PrivateInvoice AllowBillInsura nce=="0"))
||((SourcePrefi x =="70") && (PrivateInvoice AllowBillWorkCo mp="0")))

Nov 17 '05 #1
2 2830
Alpha <Al***@discussi ons.microsoft.c om> wrote:
Hi, I'm getting the following error message when I compile my program. I
tried different things but it's not working. Can someone help me look at
this and tell me what I've done wrong? Many thanks in adavnace.
error:
C:\Progs\ARComm and2003\Invoice PrePrintedContr act\frmPreview. cs(387):
Operator '||' cannot be applied to operands of type 'bool' and 'string'

source = m_dsLocal.Table s["Source"].Rows[0]["Source"].ToString();
SourcePrefix = source.Substrin g(0,2); // Prefix of pay sources

string PrivateInvoiceA llowBillInsuran ce, PrivateInvoiceA llowBillWorkCom p;

PrivateInvoiceA llowBillInsuran ce =
m_dsLocal.Table s["Global"].Rows[0]["PrivateInvoice AllowBillInsura nce"].ToString().Tri m();
PrivateInvoiceA llowBillWorkCom p =
m_dsLocal.Table s["Global"].Rows[0]["PrivateInvoice AllowBillWorkCo mp"].ToString().Tri m();

if (((SourcePrefix == "10") || (SourcePrefix== "11")|| (SourcePrefix== "20")
|| (SourcePrefix== "30"))
||(((SourcePref ix == "50")||(SourceP refix = "60")) &&
(PrivateInvoice AllowBillInsura nce=="0"))
||((SourcePrefi x =="70") && (PrivateInvoice AllowBillWorkCo mp="0")))


Look at the last expression:

(PrivateInvoice AllowBillWorkCo mp="0")

That's assigning the reference "0" to PrivateInvoiceA llowBillWorkCom p,
then the result of the expression is the reference.

I believe you meant: (PrivateInvoice AllowBillWorkCo mp=="0")

You have the same bug in SourcePrefix="6 0" as well.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
Oops! How embarrasing! I looked but I did not see! Thank you so much.

Alpha

"Jon Skeet [C# MVP]" wrote:
Alpha <Al***@discussi ons.microsoft.c om> wrote:
Hi, I'm getting the following error message when I compile my program. I
tried different things but it's not working. Can someone help me look at
this and tell me what I've done wrong? Many thanks in adavnace.
error:
C:\Progs\ARComm and2003\Invoice PrePrintedContr act\frmPreview. cs(387):
Operator '||' cannot be applied to operands of type 'bool' and 'string'

source = m_dsLocal.Table s["Source"].Rows[0]["Source"].ToString();
SourcePrefix = source.Substrin g(0,2); // Prefix of pay sources

string PrivateInvoiceA llowBillInsuran ce, PrivateInvoiceA llowBillWorkCom p;

PrivateInvoiceA llowBillInsuran ce =
m_dsLocal.Table s["Global"].Rows[0]["PrivateInvoice AllowBillInsura nce"].ToString().Tri m();
PrivateInvoiceA llowBillWorkCom p =
m_dsLocal.Table s["Global"].Rows[0]["PrivateInvoice AllowBillWorkCo mp"].ToString().Tri m();

if (((SourcePrefix == "10") || (SourcePrefix== "11")|| (SourcePrefix== "20")
|| (SourcePrefix== "30"))
||(((SourcePref ix == "50")||(SourceP refix = "60")) &&
(PrivateInvoice AllowBillInsura nce=="0"))
||((SourcePrefi x =="70") && (PrivateInvoice AllowBillWorkCo mp="0")))


Look at the last expression:

(PrivateInvoice AllowBillWorkCo mp="0")

That's assigning the reference "0" to PrivateInvoiceA llowBillWorkCom p,
then the result of the expression is the reference.

I believe you meant: (PrivateInvoice AllowBillWorkCo mp=="0")

You have the same bug in SourcePrefix="6 0" as well.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 17 '05 #3

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

Similar topics

5
8742
by: PerritoPerron | last post by:
//I need a little help with this program, it runs but the output is not correct. //Can i get some help here please u fellas??? // This Program asks for user input like 1 && 0 and prints if it is true or false // it calculates the input to perform Logical operation from input #include <iostream> using namespace std;
3
13707
by: Nagib Abi Fadel | last post by:
Is there a XOR logical operator in Postgresql, or a function for XOR ?? I only found in the docs a Binary XOR (#). I need to do the following checkup: (field1 is NULL XOR field2 is NULL XOR filed3 is NULL) i can't right it like this: (
80
35136
by: Christopher Benson-Manica | last post by:
Of course one can get the effect with appropriate use of existing operators, but a ^^ operator would make for nice symmetry (as well as useful to me in something I'm working on). Am I the only one who would find it useful? -- Christopher Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
8
2433
by: Chua Wen Ching | last post by:
Hi, I had some beginner questions. Do we need Shift << >> or Logical AND OR XOR operator in our daily programming? I am not sure why i need to use it? I had some samples of c# codes using it. Can someone share their experiences why someone should use those operators and what type of scenarios? Any good snippets and example?
23
1612
by: Cor | last post by:
Hi group, A question to the group, would it not be for a lot of the users better when there was beside "Option strict on" an "Option logical Strict on". I was automaticaly writting Textbox1.text = 0.tostring. I know what it has to be, but I did this automaticly. I find this crazy, it cannot be something else than a string, so the compiler must have to find this very easy, but for the puritains, than that
2
4121
by: ThunderMusic | last post by:
Hi, I have a value that contains flags that I must get using a bitmask. I tryied with the && operator, but the compiler outputs this error : Operator '&&' cannot be applied to operands of type 'int' and 'int' The code is the following : // MASKS.Insert = 2 if (_RightMask && (int)MASKS.Insert)
9
3749
by: marko | last post by:
/* code start */ int a = 0; /* expected evaluation and excution order with precedence in mind /* False(3) , True(1), False(2) */ if ( (a=1) == 0 || 0 != 1 && (a =2) == 1) putchar('T'); printf("%d", a); /* code end */ 2
5
2090
by: Samik2003 | last post by:
Hello, The problem is my query is not extracting the correct xml data from the database : Is there something which I am missing?? ANy help would be appriciated. Thanks, Sam. THis is the query which I am using to extract :
3
1900
by: gallows | last post by:
Hi, I wondering if there is a standard specification for evalutation of logical expressions. For instance: if (p != NULL && strlen(p) x ) do_something(); If p is actually NULL, should this code (built with a generic compiler) crash?
3
3342
by: anchitgood | last post by:
I have tried a lot but unable to correct just 1 logical error in the following code. This error is in the for loop, when fine and minutes are printed as the garbage values. Please check it out: #include<iostream> #include<string> using namespace std;
0
9672
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10436
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7538
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3722
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.