I have this method:
Private Sub SetIfNotNull(ByVal input As Object, ByRef destination As Object, ByVal ConversionType As ConversionType)
If input IsNot Nothing AndAlso input <> "" Then
Select Case ConversionType
Case DealerTrackConnection.ConversionType._String
destination = input
Case DealerTrackConnection.ConversionType._Integer
destination = Convert.ToInt32(input)
Case DealerTrackConnection.ConversionType._Double
destination = Convert.ToDouble(input)
Case DealerTrackConnection.ConversionType._Date
destination = Convert.ToDateTime(input)
Case DealerTrackConnection.ConversionType._Decimal
destination = Convert.ToDecimal(input)
End Select
End If
End Sub
And here is one call in which it fails:
SetIfNotNull(ApplicantElement.Element("suffix").Value, NewApplicant.Suffix, ConversionType._String)
If the element from the XML file is nothing (there is no tag), the method call fails. but I am checking for nothing. Why is it doing this and how would I modify the code to fix it this time and everytime.