473,401 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Class problem

mm
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

Dec 18 '05 #1
1 944
mm wrote:
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
It looks like the Double array called 'x' is never getting initialized.
It seems like you have the code to initialize it in the Prop1
procedure but that is never getting called so the array does not get
initialized.

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
<snip>
End Class


Dec 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Steve | last post by:
Hello, I'm encountering an unexpected behavior when using the "new" modifier in a derived class to hide an inherited base class property. I use "new" intentionally so I can change the Type of...
9
by: Banaticus Bart | last post by:
I wrote an abstract base class from which I've derived a few other classes. I'd like to create a base class array where each element is an instance of a derived object. I can create a base class...
21
by: Jon Slaughter | last post by:
I have a class that is basicaly duplicated throughout several files with only members names changing according to the class name yet with virtually the exact same coding going on. e.g. class...
21
by: Mark Broadbent | last post by:
Consider the following statements //------- Item i = Basket.Items; //indexer is used to return instance of class Item Basket.Items.Remove(); //method on class item is fired item i = new...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
8
by: tshad | last post by:
I cannot seem to get the asp:textbox to use classes. Style works fine. I am trying to set the textbox to act like a label in some instance so it doesn't have a border, readonly and the background...
4
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
5
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something...
3
by: Hamilton Woods | last post by:
Diehards, I developed a template matrix class back around 1992 using Borland C++ 4.5 (ancestor of C++ Builder) and haven't touched it until a few days ago. I pulled it from the freezer and...
3
by: TamusJRoyce | last post by:
Hello. This is my first thread here. My problem has probably been came across by a lot of people, but tutorials and things I've seen don't address it (usually too basic). My problem is that I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.