Message 1 of 2
null reference could result

Not applicable
04-07-2010
11:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I know some people don't like to see questions here that include any com
interop elements, but this is a dotnet question so does not belong in the
vba group.
acad2009 vbnet 2008 express
how to avoid the compiler warning:
Variable 'ArrayObjects' is used before it has been assigned a value. A null
reference exception could result at runtime.
given
Dim ArrayObjects() As AcadEntity
...some code...
Try
ReDim ArrayObjects(0)
ArrayObjects(UBound(ArrayObjects)) = oSideLine
Catch ex As ApplicationException
m_Util.Logentry("error " & ex.Message)
End Try
...more code...then...
Try
If ArrayObjects Is Nothing Then <------------here is the warning location at
"ArrayObjects"
m_Util.Logentry("error ArrayObjects Is Nothing")
Else
SelectionSetWblock.AddItems(ArrayObjects)
End If
Catch ex As ApplicationException
End Try
what should I be doing in such cases (using an array)
i wouldn't think you'd do Dim ArrayObjects() As AcadEntity = Nothing
like you might with a simple object???
thanks
mark
interop elements, but this is a dotnet question so does not belong in the
vba group.
acad2009 vbnet 2008 express
how to avoid the compiler warning:
Variable 'ArrayObjects' is used before it has been assigned a value. A null
reference exception could result at runtime.
given
Dim ArrayObjects() As AcadEntity
...some code...
Try
ReDim ArrayObjects(0)
ArrayObjects(UBound(ArrayObjects)) = oSideLine
Catch ex As ApplicationException
m_Util.Logentry("error " & ex.Message)
End Try
...more code...then...
Try
If ArrayObjects Is Nothing Then <------------here is the warning location at
"ArrayObjects"
m_Util.Logentry("error ArrayObjects Is Nothing")
Else
SelectionSetWblock.AddItems(ArrayObjects)
End If
Catch ex As ApplicationException
End Try
what should I be doing in such cases (using an array)
i wouldn't think you'd do Dim ArrayObjects() As AcadEntity = Nothing
like you might with a simple object???
thanks
mark