Putting 2 checks on the same line when Object might be Nothing

  • Thread starter Thread starter Steve Amey
  • Start date Start date
S

Steve Amey

Hi all

At the moment I am using the following code to check to see if the
oTempDataSet is not nothing and that it has tables in it:

If Not oTempDataSet Is Nothing Then
If oTempDataSet.Tables.Count > 0 Then
End If
End If

Is it possible using new language features in .NET to put both the checks on
the same line? In older versions of VB it would not be possible because if
oTempDataSet is Nothing then checking the Tables.Count property would result
in an error. I'm not sure, but I think I read something a while ago on
short-circuiting in C++ where if the first condition was false then the
second condition was not checked, even though the code is on the same line.

Thanks for any help.

Kind Regards,
Steve.
 
Hi Robby

Lovely stuff.

Just did a quick search on Short-Circuiting and guess what came up....! I
really need to put more faith in my memory, or at least do a scan of the
help files first. Thanks for your response.

Steve.
 

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