Hi all
I have this class
I copied this from this newsgroup and change this for my personal need
When I run my program I get this
First a candidate has been added via this
AddHandler cand.AnEvent, AddressOf Shp.shapeProcedure
Shp.AddShapes(cand1)
GraphicsCnt += 1
If Left(Ddata(t), 4) = "OPEN" Then
Shp.shapeCollection(GraphicsCnt).name
="OPEN"&GraphicsCnt
After this some x and y values has to be added via this
Shp.shapeCollection(ShapeIndex).x(0) = CDbl(p1(0))
And here the program said
Object variable or With block variable not set.
Use the key word new to create a object instance
What I am doing wrong
Public Class MyShapes
Public shapeCollection As New Collection
Public Sub AddShapes(ByVal aCandidate As MyShape)
shapeCollection.Add(aCandidate)
End Sub
Public Sub shapeProcedure(ByVal sender As Object, ByVal e As
EventArgs)
' code here
Console.WriteLine("Test")
End Sub
End Class
Public Class MyShape
Public Event AnEvent As EventHandler
Public Name As String
Public x As Double() ' Array with x positions
Public y As Double() ' Array with y positions
Public w As Double ' Width
Public points As Short ' # points
Public layer As Short ' Layer (1,20,21,23,27)
Public stype As Short ' Type (1,2,3,4,5,6)
Public Property Prop1(ByVal Index As Integer) As Double
Get
Return x(Index)
End Get
Set(ByVal value As Double)
If x Is Nothing Then
ReDim x(0)
Else
ReDim Preserve x(254 + 1)
End If
x(Index) = value
End Set
End Property
Public Property Prop2(ByVal Index As Integer) As Double
Get
Return y(Index)
End Get
Set(ByVal value As Double)
If y Is Nothing Then
ReDim y(0)
Else
ReDim Preserve y(254 + 1)
End If
y(Index) = value
End Set
End Property
Public Property Prop3() As Double
Get
Return w
End Get
Set(ByVal value As Double)
w = value
End Set
End Property
Public Property prop4() As Short
Get
Return points
End Get
Set(ByVal value As Short)
points = value
End Set
End Property
Public Property prop5() As Short
Get
Return layer
End Get
Set(ByVal value As Short)
layer = value
End Set
End Property
Public Property prop6() As String
Get
Return stype
End Get
Set(ByVal value As String)
stype = value
End Set
End Property
Public Property prop7() As String
Get
Return Name
End Get
Set(ByVal value As String)
Name = value
End Set
End Property
Protected Overridable Sub OnAnEvent(ByVal e As EventArgs)
RaiseEvent AnEvent(Me, e)
End Sub
End Class