Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Visual Basic Associative Array

Posted on 1997-07-09
1
Medium Priority
?
933 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…
Suggested Courses

618 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