S
Steven M (remove wax and invalid to reply)
I have a couple of classes, including PointClass:
Private X As Double
Private Y As Double
Another is myListClass. Its purpose is to manage a list containing a
variable number of points:
Private mCurrentSize As Long
Private mMaxSize as Long
Private mList() As PointClass
' mCurrentSize is the number of points currently stored
' mMaxSize is the current size of array mList
==========
Next, I create this subroutine in the class, to add a new point to the
list:
==========
Public Sub AddPoint (NewPoint As PointClass)
If mCurrentSize = mMaxSize Then
ReDim Preserve mList (2 * mCurrentSize)
mMaxSize = mMaxSize * 2
End If
mCurrentSize = mCurrentSize + 1
mList(mCurrentSize).X = NewPoint.X
mList(mCurrentSize).Y = NewPoint.Y
End Sub
==========
Then I created this test stub. It compiles and starts to run, but ...
==========
Sub stub()
Dim thisList As myListClass
Dim TestPoint As PointClass
Set thisList = New myListClass
Set TestPoint = New PointClass
TestPoint.X = 300
TestPoint.Y = 500
' fails on this line:
thisList.AddPoint (TestPoint)
End Sub
==========
It fails when it calls "AddPoint". The error message is:
- - - - - - - - - - - -
Run-time error '438':
Object doesn't support this property or method
- - - - - - - - - - - -
Why doesn't this work? How can I fix it?
Do I need to use a "New" statement to initialize the mList array?
Do I need a constructor for myListClass? I tried this, but it didn't
eliminate the error:
==========
Private Sub Class_Initialize()
mCurrentSize = 0
End Sub
==========
Is there a better approach?
Thanks.
--
Steven M - (e-mail address removed)
(remove wax and invalid to reply)
bus station = where bus stops
train station = where train stops
work station = ?
Private X As Double
Private Y As Double
Another is myListClass. Its purpose is to manage a list containing a
variable number of points:
Private mCurrentSize As Long
Private mMaxSize as Long
Private mList() As PointClass
' mCurrentSize is the number of points currently stored
' mMaxSize is the current size of array mList
==========
Next, I create this subroutine in the class, to add a new point to the
list:
==========
Public Sub AddPoint (NewPoint As PointClass)
If mCurrentSize = mMaxSize Then
ReDim Preserve mList (2 * mCurrentSize)
mMaxSize = mMaxSize * 2
End If
mCurrentSize = mCurrentSize + 1
mList(mCurrentSize).X = NewPoint.X
mList(mCurrentSize).Y = NewPoint.Y
End Sub
==========
Then I created this test stub. It compiles and starts to run, but ...
==========
Sub stub()
Dim thisList As myListClass
Dim TestPoint As PointClass
Set thisList = New myListClass
Set TestPoint = New PointClass
TestPoint.X = 300
TestPoint.Y = 500
' fails on this line:
thisList.AddPoint (TestPoint)
End Sub
==========
It fails when it calls "AddPoint". The error message is:
- - - - - - - - - - - -
Run-time error '438':
Object doesn't support this property or method
- - - - - - - - - - - -
Why doesn't this work? How can I fix it?
Do I need to use a "New" statement to initialize the mList array?
Do I need a constructor for myListClass? I tried this, but it didn't
eliminate the error:
==========
Private Sub Class_Initialize()
mCurrentSize = 0
End Sub
==========
Is there a better approach?
Thanks.
--
Steven M - (e-mail address removed)
(remove wax and invalid to reply)
bus station = where bus stops
train station = where train stops
work station = ?