Solved

assign properties to array elements

Posted on 2010-11-22
6
386 Views
Last Modified: 2012-08-14
What is the best approach for creating my own properties to items in an array?

For example, I will have an array of places.  The Array will be populated by a list created by the user on an excel worksheet.  I would like each place to have properties, such as name, etc., etc.  Some properties will be assigned through the list the user created, others will be assigned from external data (Web Query).  

I'm thinking (after being setup properly) assigning a value to the property would look something like this: place(i).name = "Hell".

Any insight is appreciated, thanks.
0
Comment
Question by:growedup
[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
6 Comments
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 400 total points
ID: 34186783
You could declare a type and then assign the type of the variable to that i.e.

type fred
    place as string
    name as string
end type

dim arr(1 to 3) as fred

arr(1).name = "norman"
arr(1).place = "hell"

Chris
0
 
LVL 18

Expert Comment

by:x-men
ID: 34186785
crate an array within the array
properteis[0] = "hell" ' Name
properteis[1] = .. ' other property
...

Places(i,properties(x))
0
 
LVL 18

Expert Comment

by:x-men
ID: 34186789
Places(i,properties(x)) is not in the ccoorect syntax
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 23

Assisted Solution

by:Michael Fowler
Michael Fowler earned 100 total points
ID: 34186984
you could always use a dictionary instead of an array.
Have a look at
http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/A_3391-Using-the-Dictionary-Class-in-VBA.html
for more info on this class
0
 

Author Closing Comment

by:growedup
ID: 34187425
For this project, declaring a type is the best solution.  Using a dictionary is a great solution as well, but is too complex for this project.  I will definately be considering it for future projects though.
0
 

Author Comment

by:growedup
ID: 34187429
Thanks for all the fast inputs everyone!
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

635 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