Creating an array of graphic paths in vb.net
I dont know Why I am having trouble with this, but I keep getting 'not set to an instance of an object' exception every time.
Does this make sense?
I have this declared in the main form
Private _Paths() As System.Drawing.Drawing2D.GraphicsPath
and do this in a sub
_Paths(20) = New GraphicsPath
But for whatever reason I get an object reference error on the second line. Any help?
After the decleration, I want to then go ahead and add a line to the graphics path like so
_Paths(k).AddLine(x_loc(k), y_loc(k), x_loc(k + 1), y_loc(k + 1))
As per suggestion to use list:
Declared in main class
Private _Paths As List(Of System.Drawing.Drawing2D.GraphicsPath)
using in sub
for k = 0 to 10 'x_loc and y_loc calculations are done here _Paths.Add(New GraphicsPath) _Paths(k).AddLine(x_loc(k), y_loc(k), x_loc(k + 1), y_loc(k + 1)) next
still get error when trying to create new instance of graphicspath
There should be no reason this error should pop up right?
Private _Paths As NEW List(Of System.Drawing.Drawing2D.GraphicsPath)
Your not redimensioning your array, instead use a List(Of GraphicsPath) and just .Add them as you need.
Dim myPaths As New List(Of GraphicsPath) 'later in code myPaths.Add(New GraphicsPath) myPaths(0).AddLine(...)'etc...