|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Is this logic correct?Would one of you who understands VB conditionals better than I please confirm if the logic is correct? I can't figure out where the final AND binds to in the conditional. Here's the problem conditional: If Not IsNumeric(str1) Or (Len(str1)>16 Or (Len(str1)<14 And Len(str1)<>5) And str2="L") Then ' stuff End If The above, simplified, boils down to if A Or (B Or (C And D) And E) then.... Given the above logic, which of these conditions resolve to true or false? if 1 or (0 or (0 and 0) and 0) then true or false? if 0 or (1 or (0 and 0) and 0) then true or false? if 0 or (0 or (1 and 0) and 0) then true or false? if 0 or (0 or (0 and 0) and 1) then true or false? if 1 or (0 or (0 and 0) and 1) then true or false? if 0 or (1 or (0 and 0) and 1) then true or false? if 0 or (0 or (1 and 0) and 1) then true or false?
Show quote
Hide quote
"Richard Lewis Haggard" <HaggardAtWorldDotStdDotCom> wrote in message I don't think there can be any difference in the rules of precedence in both news:O6$q%23z4JGHA.1532@TK2MSFTNGP12.phx.gbl... > I'm porting some VB to C# and have run into a conditional that seems odd. > Would one of you who understands VB conditionals better than I please > confirm if the logic is correct? I can't figure out where the final AND > binds to in the conditional. > > Here's the problem conditional: > If Not IsNumeric(str1) Or (Len(str1)>16 Or (Len(str1)<14 And Len(str1)<>5) > And str2="L") Then > ' stuff > End If > > The above, simplified, boils down to > > if A Or (B Or (C And D) And E) then.... > > Given the above logic, which of these conditions resolve to true or false? > if 1 or (0 or (0 and 0) and 0) then true or false? > if 0 or (1 or (0 and 0) and 0) then true or false? > if 0 or (0 or (1 and 0) and 0) then true or false? > if 0 or (0 or (0 and 0) and 1) then true or false? > > if 1 or (0 or (0 and 0) and 1) then true or false? > if 0 or (1 or (0 and 0) and 1) then true or false? > if 0 or (0 or (1 and 0) and 1) then true or false? > -- > Richard Lewis Haggard > www.Haggard-And-Associates.com > languages. So precedence is (only those operators, used in given expressions): parentheses, NOT, AND, OR. Same level of precedence evaluated from left to right. To simplify task, I've replaced 0s/1s with False/True and run them in VB Debug.Print True Or (False Or (False And False) And False) Debug.Print False Or (True Or (False And False) And False) Debug.Print False Or (False Or (True And False) And False) Debug.Print False Or (False Or (False And False) And True) Debug.Print True Or (False Or (False And False) And True) Debug.Print False Or (True Or (False And False) And True) Debug.Print False Or (False Or (True And False) And True) Results (in the same order): True True False False True True False Dmitriy Dmitriy Antonov wrote:
Show quoteHide quote > "Richard Lewis Haggard" <HaggardAtWorldDotStdDotCom> wrote ... But there _is_ a difference in the "value of True" and how boolean operators>> I'm porting some VB to C# and have run into a conditional that seems >> odd. Would one of you who understands VB conditionals better than I >> please confirm if the logic is correct? I can't figure out where the >> final AND binds to in the conditional. >> >> Here's the problem conditional: >> If Not IsNumeric(str1) Or (Len(str1)>16 Or (Len(str1)<14 And >> Len(str1)<>5) And str2="L") Then >> ' stuff >> End If >> >> The above, simplified, boils down to >> >> if A Or (B Or (C And D) And E) then.... >> >> Given the above logic, which of these conditions resolve to true or >> false? if 1 or (0 or (0 and 0) and 0) then true or false? >> if 0 or (1 or (0 and 0) and 0) then true or false? >> if 0 or (0 or (1 and 0) and 0) then true or false? >> if 0 or (0 or (0 and 0) and 1) then true or false? >> >> if 1 or (0 or (0 and 0) and 1) then true or false? >> if 0 or (1 or (0 and 0) and 1) then true or false? >> if 0 or (0 or (1 and 0) and 1) then true or false? > > I don't think there can be any difference in the rules of precedence > in both languages. work. Show quoteHide quote > So precedence is (only those operators, used in That's a far better way to think of it, yes!> given expressions): parentheses, NOT, AND, OR. Same level of > precedence evaluated from left to right. > > To simplify task, I've replaced 0s/1s with False/True and run them in > VB > > Debug.Print True Or (False Or (False And False) And False) > Debug.Print False Or (True Or (False And False) And False) > Debug.Print False Or (False Or (True And False) And False) > Debug.Print False Or (False Or (False And False) And True) > Debug.Print True Or (False Or (False And False) And True) > Debug.Print False Or (True Or (False And False) And True) > Debug.Print False Or (False Or (True And False) And True) > > Results (in the same order): > > True > True > False > False > True > True > False
Do we have such a container control?
www Link in VB 6... Book for web dev with VS2005? Need help regarding the program... Please help me.. It's very Urgent missing reference Connection Recordset to FlexGrid Word find.selection on formatted text? Run-time error 3706 Monthview control - run time 380 invalid property value |
|||||||||||||||||||||||