?
Solved

Visual Basic Associative Array

Posted on 1997-07-09
1
Medium Priority
?
884 Views
Last Modified: 2013-11-25
Is there any built-in or 3rd party Associative Array data (like the one in Java or Perl) type in VB 5? If 3rd party control is available, where can I find it?
0
Comment
Question by:zrokool
[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
1 Comment
 
LVL 3

Accepted Solution

by:
CesarGon earned 200 total points
ID: 1428156
Use collections. Collections are built in VB5, and behave as maps (or associative arrays) from a string to an object. Sample code:

  'create collection and a work variable.
  Dim col as New Collection
  Dim ob as Object

  'create and insert one object into collection.  
  Set ob = New Object
  ob.Prop1 = "Some Text"
  col.Add ob, "First"

  'create and insert another object.  
  Set ob = New Object
  ob.Prop1 = "Some Other Text"
  col.Add ob, "Second"
 
  'retrieve one object.
  Set ob = col("First")

  'directly use object in collection.
  Debug.Print col("Second").Prop1

Ask if you need more info.

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

771 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