Click here to Skip to main content
15,921,279 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am writing a very elementary bunch of vb net code, which is basically :

VB
Dim hsProd as Hashtable = Nothing

if not IsNothing (hsProd) then 
' do some stuff
end if 


I happen to always enter the "do some stuff" code .... why ?

What I have tried:

if not (hsProd is nothing) then.....

if isnothing (hsProd) = false then .....

if hsProd isnot nothing then .....

none of them worked
Posted
Updated 30-Mar-16 0:59am
v2

1 solution

Try:
VB.NET
Dim hsProd as Hashtable = Nothing
If hsProd IsNot Nothing then 
   ' Do stuff
Else
   ' Do other stuff
End If 
 
Share this answer
 
Comments
tiwal 30-Mar-16 15:40pm    
already tried , it didn't work either
OriginalGriff 31-Mar-16 3:48am    
Strange - because when I did, it did...
So what about my code was different from yours?
tiwal 31-Mar-16 9:37am    
that's what I am asking myself ....
OriginalGriff 31-Mar-16 10:00am    
So? If I copy the code above, it works. what happens if you copy it?
For example:
Sub Main()
Dim hsProd As Hashtable = Nothing
If hsProd IsNot Nothing Then
Console.WriteLine(" Do stuff")
Else
Console.WriteLine(" Do other stuff")
End If
End Sub

Produces: " Do other stuff"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900