test for Nothing and values on the same line?

  • Thread starter Thread starter Craig Buchanan
  • Start date Start date
C

Craig Buchanan

I'm trying to deterime if an instance of an object exists and if so, if it
has a certain value. This syntax tosses an error:

If (Not LastItem Is Nothing) And LastItem.Cells(3).Text = Item.Cells(3).Text
Then Exit Sub

Other than having a nested If Then block, is there another way?



Thanks,



Craig Buchanan
 
Craig said:
I'm trying to deterime if an instance of an object exists and if so, if it
has a certain value. This syntax tosses an error:

If (Not LastItem Is Nothing) And LastItem.Cells(3).Text = Item.Cells(3).Text
Then Exit Sub

Other than having a nested If Then block, is there another way?



Thanks,



Craig Buchanan

Replace And with AndAlso...that keyword only executes the next
expression if the first one is true

Its counterpart is OrElse
 
Craig said:
I'm trying to deterime if an instance of an object exists and if so, if it
has a certain value. This syntax tosses an error:

If (Not LastItem Is Nothing) And LastItem.Cells(3).Text = Item.Cells(3).Text
Then Exit Sub

Other than having a nested If Then block, is there another way?



Thanks,



Craig Buchanan

Replace And with AndAlso...that keyword only executes the next
expression if the first one is true

Its counterpart is OrElse
 

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