D
Dave
Hi All,
I am new to OOP and new to VB.net and have an object/Class question. I want
to create and array of objects. Each object needs to have a Property that is
and array.
Basicly here is what I have to initialize my objects
Dim MyObject() as MyClass
For x = 0 to 5
Dim MyObject(x) as MyClass
Next
It seems to let me do the above but when I call the Method AddArray() I get
an 'NullReferenceexeption was unhandled ' error that also says 'Object
reference not set to an instance of an object.' As seen below
MyObject(x).AddMyArray(5) - This throws the error
Here is my AddMyArray method as it is in my class
Public Sub AddMyArray(ByVal value As Integer)
Dim x As Integer
Dim dblWeight(value - 1) 'Private value in my class
For x = 0 To (value - 1)
dblWeight(x) = 0
Next
End Sub
I guess what I don't understand is why my object MyObject(x) is null after I
have declared it. What am I doing wrong?
I am new to OOP and new to VB.net and have an object/Class question. I want
to create and array of objects. Each object needs to have a Property that is
and array.
Basicly here is what I have to initialize my objects
Dim MyObject() as MyClass
For x = 0 to 5
Dim MyObject(x) as MyClass
Next
It seems to let me do the above but when I call the Method AddArray() I get
an 'NullReferenceexeption was unhandled ' error that also says 'Object
reference not set to an instance of an object.' As seen below
MyObject(x).AddMyArray(5) - This throws the error
Here is my AddMyArray method as it is in my class
Public Sub AddMyArray(ByVal value As Integer)
Dim x As Integer
Dim dblWeight(value - 1) 'Private value in my class
For x = 0 To (value - 1)
dblWeight(x) = 0
Next
End Sub
I guess what I don't understand is why my object MyObject(x) is null after I
have declared it. What am I doing wrong?