T
tinman
Hi....
There appears to be another way of checking if an object IsNothing in
..NET.....was wondering if this approach is better than the classic VB6 way
of checking Is Nothing ?
Example
******
Public Function IsNothing(ByVal ExternalObject As Object) As Boolean
Try
Return (ExternalObject.Equals(New System.Object))
Catch ex As NullReferenceException
Return True
End Try
End Function
Private Sub Testing()
Dim objX as ClassX
Debug.WriteLine IsNothing(objX) 'Returns True
objX = New ClassX
Debug.WriteLine IsNothing(objX) 'Returns False
objX = Nothing
Debug.WriteLine IsNothing(objX) 'Returns True
End Sub
There appears to be another way of checking if an object IsNothing in
..NET.....was wondering if this approach is better than the classic VB6 way
of checking Is Nothing ?
Example
******
Public Function IsNothing(ByVal ExternalObject As Object) As Boolean
Try
Return (ExternalObject.Equals(New System.Object))
Catch ex As NullReferenceException
Return True
End Try
End Function
Private Sub Testing()
Dim objX as ClassX
Debug.WriteLine IsNothing(objX) 'Returns True
objX = New ClassX
Debug.WriteLine IsNothing(objX) 'Returns False
objX = Nothing
Debug.WriteLine IsNothing(objX) 'Returns True
End Sub