Help with logical operator

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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\frmPreview.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")))
 
Alpha said:
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\frmPreview.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.
 
Oops! How embarrasing! I looked but I did not see! Thank you so much.

Alpha

Jon Skeet said:
Alpha said:
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\frmPreview.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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top