473,480 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Create 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\ARCommand2003\InvoicePrePrintedContract\f rmPreview.cs(387):
Operator '||' cannot be applied to operands of type 'bool' and 'string'

source = m_dsLocal.Tables["Source"].Rows[0]["Source"].ToString();
SourcePrefix = source.Substring(0,2); // Prefix of pay sources

string PrivateInvoiceAllowBillInsurance, PrivateInvoiceAllowBillWorkComp;

PrivateInvoiceAllowBillInsurance =
m_dsLocal.Tables["Global"].Rows[0]["PrivateInvoiceAllowBillInsurance"].ToString().Trim();
PrivateInvoiceAllowBillWorkComp =
m_dsLocal.Tables["Global"].Rows[0]["PrivateInvoiceAllowBillWorkComp"].ToString().Trim();

if (((SourcePrefix == "10") || (SourcePrefix=="11")|| (SourcePrefix=="20")
|| (SourcePrefix=="30"))
||(((SourcePrefix == "50")||(SourcePrefix = "60")) &&
(PrivateInvoiceAllowBillInsurance=="0"))
||((SourcePrefix =="70") && (PrivateInvoiceAllowBillWorkComp="0")))

Nov 17 '05 #1
2 2813
Alpha <Al***@discussions.microsoft.com> 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\ARCommand2003\InvoicePrePrintedContract\f rmPreview.cs(387):
Operator '||' cannot be applied to operands of type 'bool' and 'string'

source = m_dsLocal.Tables["Source"].Rows[0]["Source"].ToString();
SourcePrefix = source.Substring(0,2); // Prefix of pay sources

string PrivateInvoiceAllowBillInsurance, PrivateInvoiceAllowBillWorkComp;

PrivateInvoiceAllowBillInsurance =
m_dsLocal.Tables["Global"].Rows[0]["PrivateInvoiceAllowBillInsurance"].ToString().Trim();
PrivateInvoiceAllowBillWorkComp =
m_dsLocal.Tables["Global"].Rows[0]["PrivateInvoiceAllowBillWorkComp"].ToString().Trim();

if (((SourcePrefix == "10") || (SourcePrefix=="11")|| (SourcePrefix=="20")
|| (SourcePrefix=="30"))
||(((SourcePrefix == "50")||(SourcePrefix = "60")) &&
(PrivateInvoiceAllowBillInsurance=="0"))
||((SourcePrefix =="70") && (PrivateInvoiceAllowBillWorkComp="0")))


Look at the last expression:

(PrivateInvoiceAllowBillWorkComp="0")

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

I believe you meant: (PrivateInvoiceAllowBillWorkComp=="0")

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

--
Jon Skeet - <sk***@pobox.com>
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***@discussions.microsoft.com> 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\ARCommand2003\InvoicePrePrintedContract\f rmPreview.cs(387):
Operator '||' cannot be applied to operands of type 'bool' and 'string'

source = m_dsLocal.Tables["Source"].Rows[0]["Source"].ToString();
SourcePrefix = source.Substring(0,2); // Prefix of pay sources

string PrivateInvoiceAllowBillInsurance, PrivateInvoiceAllowBillWorkComp;

PrivateInvoiceAllowBillInsurance =
m_dsLocal.Tables["Global"].Rows[0]["PrivateInvoiceAllowBillInsurance"].ToString().Trim();
PrivateInvoiceAllowBillWorkComp =
m_dsLocal.Tables["Global"].Rows[0]["PrivateInvoiceAllowBillWorkComp"].ToString().Trim();

if (((SourcePrefix == "10") || (SourcePrefix=="11")|| (SourcePrefix=="20")
|| (SourcePrefix=="30"))
||(((SourcePrefix == "50")||(SourcePrefix = "60")) &&
(PrivateInvoiceAllowBillInsurance=="0"))
||((SourcePrefix =="70") && (PrivateInvoiceAllowBillWorkComp="0")))


Look at the last expression:

(PrivateInvoiceAllowBillWorkComp="0")

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

I believe you meant: (PrivateInvoiceAllowBillWorkComp=="0")

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

--
Jon Skeet - <sk***@pobox.com>
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
8721
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...
3
13652
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...
80
35014
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...
8
2405
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. ...
23
1571
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...
2
4097
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...
9
3724
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');...
5
2063
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...
3
1879
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...
3
3319
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: ...
0
7044
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,...
1
6741
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...
0
6944
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...
0
5341
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,...
1
4782
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...
0
4483
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...
0
2985
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1300
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 ...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.