?
Solved

Array in a collection class thing.

Posted on 2003-03-02
4
Medium Priority
?
158 Views
Last Modified: 2012-05-04
I am wondering how to have an array inside a collection class thingy, and write the let and get statements for it.  For example  I have this as a normal variable in it:

Private m_Name As String
Public Property Get Name() As String
    Name = m_Name
End Property
Public Property Let Name(ByVal v_Name As String)
    m_Name = v_Name
End Property


How would I write the let and get part for this:

Private m_MyArray(1 To 99, 1 To 99) As Single


Thanx, Jebus
0
Comment
Question by:dj__jebus
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
QJohnson earned 200 total points
ID: 8055162
Public Property Let MyArray(intDim1 As Integer, intDim2 As Integer, sglValue As Single)
   m_MyArray(intDim1, intDim2) = sglValue
End Property


Public Property Get MyArray(intDim1 As Integer, intDim2 As intger) As Single
   MyArray = m_MyArray(intDim1, intDim2)
End Property
0
 

Author Comment

by:dj__jebus
ID: 8061847
Thanx QJohnson, it seems to be working fine in adding objects to the collection and all that.  However, I seem to have a problem in reading them back again. This is what I'm trying:

myVariable = collectionName.Item(n).propertyName(var1, var2)

I get runtime error '438' "Object doesn't support this propert or method.

Thanx, Jebus
0
 
LVL 3

Expert Comment

by:QJohnson
ID: 8064168
Looks like it should work to me.

So I would try "other stuff like it" and see if the results change.

For example:

dim myTempObject as MyClassName

set myTempObject = collectionName.Item(n)
myVariable = myTempObject.propertyName(var1, var2)

I have seen some interesting variation in results depending on 'how many dots' are used in code for object referencing.  (By this I mean using With/End With to reduce the depth of object references, i.e. fewer dots.) In each case, the fewer has always worked better.

So you might try this, too:

with collectionName.Item(n)
      myVariable = .propertyName(var1, var2)
end with

It is probably also worth testing that the var1, var2 arguments are both of the proper type.  And you should probably check in the debugger before the code you test here (and your own code) executes to be sure that Item(n) is Not Nothing and that it's propertyName array has been properly initialized.

Q
0
 

Author Comment

by:dj__jebus
ID: 8065389
Ok, Thanx, I got it to work by a combination of creating a temp object and the with/end thing.


Thanx, Jebus
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question