According to the Debugger, I've got a variable called myCancelled
of type Newtonsoft.Json.Linq.Jtoken with a value of Nothing. I also casted it to Object and all of these conditions fail. My question is simply: How do I check if it's Nothing/Null/False/Empty?
Here's what I've tried. None of these conditions evaluate to true:
If myCancelled Is Nothing Then
'Doesn't come here
End If
If myCancelled = DBNull.Value.ToString Then
'Doesn't come here
End If
If myCancelled = "null" Then
'Doesn't come here
End If
If IsDBNull(myCancelled) Then
'Doesn't come here
End If
If myCancelled Is DBNull.Value Then
'Doesn't come here
End If
If String.IsNullOrEmpty(myCancelled) = True Then
'Doesn't come here
End If
If myCancelled.ToString = "Nothing" Then
'Runtime error
End If
If myCancelled = DBNull.Value Then
'Runtime error
End If
If IsNothing(myCancelled) Then
'Doesn't come here
End If
I'm new to VB.net so any pointers are appreciated.
EDIT
This one worked, but it lets False-positives through (when myCancelled has it value, the conditional is true)
If Not myCancelled Then
' It comes here
End If
This is what worked. VB is hard to learn when you get used to Java, C#, etc.
If Not myCancelled.Equals("Y") Then
' It finally came here
End If