Solved

assign properties to array elements

Posted on 2010-11-22
6
346 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
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 23

Assisted Solution

by:Michael74
Michael74 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
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.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now