VB also has null propagation these days, so you can say "get this member if the object exists, otherwise get Nothing":
vb.net Code:
Dim strEventId As String
strEventId = aobjxmlNotificationEventNode.SelectSingleNode("@elementKey").InnerText
Dim CompDate = aobjXmlInputDoc.DocumentElement.SelectSingleNode("Case/CaseEvent[@ID=" + strEventId + "]/CompDate")?.InnerText
If CompDate IsNot Nothing Then
objInsertPWBRorAOS.CompletedDate = CDate(CompDate)
End If
This:
is functionally equivalent to this:
vb.net Code:
If y Is Nothing Then
x = Nothing
Else
x = y.z
End If
One of the cool things is that, because you can use the null propagation operator anywhere you would use a standard member access operator, you can chain them together, e.g.
That is functionally equivalent to this:
vb.net Code:
If b Is Nothing OrElse b.c Is Nothing OrElse b.c.d Is Nothing Then
a = Nothing
Else
a = b.c.d.e
End If
Note that null propagation only works for reference types or nullable value types.