Solved

Visual Basic Associative Array

Posted on 1997-07-09
1
766 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
1 Comment
 
LVL 3

Accepted Solution

by:
CesarGon earned 50 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
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…

706 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

15 Experts available now in Live!

Get 1:1 Help Now