test for Nothing and values on the same line?

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
 
C

Craig Deelsnyder

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
 
C

Craig Deelsnyder

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top