Operator precedance

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Boni

    #1

    Operator precedance

    Dear All,

    I am wondering that followind produces an exception if Startline is
    Nothzing.

    In C++ is first operation is true it would be enougth for the or statement
    to be true.

    If elem.StartLine Is Nothing Or elem.StartLine. ParentLine Is Nothing Then
    ....

    Is there some setting to eleminate it?

    Thanks,

    Boni


  • Herfried K. Wagner [MVP]

    #2
    Re: Operator precedance

    "Boni" <oilia@nospam > schrieb:[color=blue]
    > I am wondering that followind produces an exception if Startline is
    > Nothzing.
    >
    > In C++ is first operation is true it would be enougth for the or statement
    > to be true.
    >
    > If elem.StartLine Is Nothing Or elem.StartLine. ParentLine Is Nothing Then[/color]

    Take a look at the documentation for the 'Or' and 'OrElse' operator.
    'OrElse' will perform short-circuiting.

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://classicvb.org/petition/>

    Comment

    • Cor Ligthert

      #3
      Re: Operator precedance

      Boni,

      That is the same in VBNet, however in VB they both are evaluated when it is
      the Or.

      To avoid that is created the operator OrElse. That acts as in every other
      program language the Or.

      I hope this helps,

      Cor


      Comment

      Working...