Constructors: NewArgumentNullException |
Creates a new ArgumentNullException object.
Public Function NewArgumentNullException( Optional ByRef ParamName As String, Optional ByRef Message As String, Optional ByVal InnerException As Exception ) As ArgumentNullException
When throwing an ArgumentNullException a meaningful error message describing the invalid argument and the name of the argument should be defined.
' Throws a default ArgumentNullException object Throw New ArgumentNullException ' Throws an ArgumentNullException with a custom message and parameter name Throw Cor.NewArgumentNullException("MyParam", "A valid object is required.") ' Throws an ArgumentNullException with a custom message and error code and parameter name Dim ex As ArgumentNullException Set ex = Cor.NewArgumentNullException("MyParam", "A valid object is required.") ex.HResult = 123 Throw exThis example shows how to throw three different variations of the same ArgumentNullException object.