?
Solved

Array in a collection class thing.

Posted on 2003-03-02
4
Medium Priority
?
154 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

801 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