J. Scott Elblein
Well-known member
Hi
Ok, here is my strange problem that i know I must be spacing out on:
I am trying to detect when an object is nothing, and if so, just skip along (It is in a loop that is not shown). What is the difference between these 2 code samples?
Sample 1:
Sample 2:
I am preferring to use Sample 2 because it's a bit cleaner.
Sample 1 is working as intended, when it comes into an object that is nothing, it does nothing and we end up looping back around again.
Sample 2, which seems to be the same thing to me as Sample 1, is not working as intended, and in my try Catch block, goes to the exception which tells me I need to either use New or check for Null.
How come?
Ok, here is my strange problem that i know I must be spacing out on:
I am trying to detect when an object is nothing, and if so, just skip along (It is in a loop that is not shown). What is the difference between these 2 code samples?
Sample 1:
VB.NET:
If link.InnerHtml Is Nothing = True Then
Console.WriteLine("Object was nothing")
Else
If link.InnerHtml.Contains("Pro") = False Then
' Do stuff
End If
End If
Sample 2:
VB.NET:
If link.InnerHtml Is Nothing = False And link.InnerHtml.Contains("Pro") = False Then
' Do stuff
End If
I am preferring to use Sample 2 because it's a bit cleaner.
Sample 1 is working as intended, when it comes into an object that is nothing, it does nothing and we end up looping back around again.
Sample 2, which seems to be the same thing to me as Sample 1, is not working as intended, and in my try Catch block, goes to the exception which tells me I need to either use New or check for Null.
How come?