Operator precedance

  • Thread starter Thread starter Boni
  • Start date Start date
B

Boni

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
 
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
 
Boni said:
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

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

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

Similar Threads

Where to take cursors 5
ToolTip question 5
Subscript out of range 7
Special tree view 1
Converting access report to PDF in 2007 1
Strange tooltip on treeview 1
Line srawing 3
Atomic Operation? 7

Back
Top