Checking for nothing

  • Thread starter Thread starter John
  • Start date Start date
Hi

How can I check a variable for Nothing?

Thanks

Regards

if variable is nothing then
MessageBox.Show("Gasp!")
end if

Thanks,

Seth Rowe
 
If myVariable Is Nothing Then

End If

If myVariable IsNot Nothing Then

End If

If Not myVariable Is Nothing Then

End If
 
If foo is a reference type:
"If foo Is Nothing Then"

If foo is a value type:
"If foo = Nothing Then"
Note that for value types, the check for equality with Nothing just checks
whether the value is the default value for the value type.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
 

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