I'm sure this one is easy...
How do I check if an object contains a Null reference?
Thanks in advance
Printable View
I'm sure this one is easy...
How do I check if an object contains a Null reference?
Thanks in advance
easy indeed... with Is Nothing :D
You might want to take note that IsNull and IsEmpty from VB6 have been declared obsolete in VB.Net. You can now use IsDBNull() which takes an object as a parameter and returns a boolean value indicating wether the variable has been initialized.
You can also work with the DBNull class which is part of the System namespace. Ill give you examples of bolth methods for comparison puposes.
Code:Dim sysNull as System.DBNull
Dim strString as String
If strString is sysNull Then
strString = " String is now initialized"
End If
If Not IsDBNull(sysString) Then
Debug.WriteLine strString
End If