• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 654
  • Last Modified:

"If {AdoConnection} IsNot Nothing Then" vs "If Not {AdoConnection} Is Nothing Then"

Is one better to use than the other?  Is there another way of checking if something (in this case, an ADO Connection object) is nothing.

In VB6, I would write:

If Not {AdoConnection} Is Nothing Then
   ...
End If

In VB.NET, neither the above nor the following generate an error:

If {AdoConnection} IsNot Nothing Then
   ...
End If


0
CarlaGibson
Asked:
CarlaGibson
  • 2
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
what about
If Not IsNothing({AdoConnection}) Then
   ...
End If

Open in new window

0
 
CarlaGibsonAuthor Commented:
Does it matter which way is used?  They all give the same results.  Is it just personal preference or is there a reason to use one over the other?
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
> They all give the same results.
the only difference could then be performance, right?!

in which case, IsNothing is a function call, which will have a slight overhead over the other methods.
0
 
CarlaGibsonAuthor Commented:
Thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now