473,396 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Associative Array using Visual Basic 6

I want to create an associative array, similar to PERL language, using Visual Basic 6.

Example: Using PERL

%A = ("A"=>"Apple","B"=>"Banana");

i.e., A is associated to the word Apple and B is associated to the word Banana. The alternative conversion is:

$A{'A'} = "Apple";
$A{'B'} = "Banana";

Similarly i want the conversion in Visual Basic 6. Is it possible?

---------------------------------------------
T. Ashok Kumar
<email address removed>
____________________________
Aug 5 '07 #1
6 6948
JosAH
11,448 Expert 8TB
You're better off asking this question in the Visual Basic forum.

kind regards,

Jos
Aug 5 '07 #2
bartonc
6,596 Expert 4TB
I've removed you email address. Please see our Posting Guidelines. Thank you.

Also moving from Member Introductions to the VB Forum.
Aug 5 '07 #3
Killer42
8,435 Expert 8TB
Definitely. What you're looking for is a Collection. It works in many ways similarly to an array, but rather than (or as well as) a numeric index, you can access it via a key that you supply when creating it.

Check the doco for Collection.

There is also a Dictionary object which I've heard is better in some ways than a collection, but I'm not familiar with it.
Aug 6 '07 #4
Try this code

'General
Dim A(10) as String

'form load
sub form_load ()
A(0) = "Apple"
A(1)= "Banana"
end sub

this code will let you enter 11 String data in your array from A(0) to A(10) and you can also get the data the same way like

text1.text = A(0) 'in the text you get Apple
text2.text = A(1) 'in the text you get Banana

you can also dim you array as integer , double or any other

I wish that help you
Aug 6 '07 #5
hariharanmca
1,977 1GB
tray this code

you can also dim you array as integer , double or any other

I wish that help you
Good Hassan, But he is looking for

$A{'A'} = "Apple";
$A{'B'} = "Banana";
and he never explain his requirement to give better suggessions.
Aug 6 '07 #6
Killer42
8,435 Expert 8TB
Yes, the question is not merely how to use an array, but how to use a key such as "A" or "B" to look something up "automatically" in the array. That's why I suggested using a Collection, which I believe covers this situation pretty well.
Aug 6 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

27
by: Abdullah Kauchali | last post by:
Hi folks, Can one rely on the order of keys inserted into an associative Javascript array? For example: var o = new Object(); o = "Adam"; o = "Eve";
2
by: Zenobia | last post by:
I have a problem. I need to look up several values stored in arrays. Each value is stored as a pair. The first (number) represents the probability of this item occurring. For instance, in the...
6
by: mark4asp | last post by:
Suppose I have the following code. It functions to randomly select a city based upon the probabilities given by the key differences in the associative array. . Eg. because the key difference...
4
by: Robert | last post by:
I am curious why some people feel that Javascript doesn't have associative arrays. I got these definitions of associative arrays via goggle: Arrays in which the indices may be numbers or...
8
by: Derek Basch | last post by:
Is there any way to associate name/value pairs during an array initialization? Like so: sType = "funFilter" filterTypeInfo = ; filterTypeInfo = new Array("type" : sType); I can do it using...
47
by: VK | last post by:
Or why I just did myArray = "Computers" but myArray.length is showing 0. What a hey? There is a new trend to treat arrays and hashes as they were some variations of the same thing. But they...
7
by: Robert Mark Bram | last post by:
Hi All! How do you get the length of an associative array? var my_cars= new Array() my_cars="Mustang"; my_cars="Station Wagon"; my_cars="SUV"; alert(my_cars.length);
41
by: Rene Nyffenegger | last post by:
Hello everyone. I am not fluent in JavaScript, so I might overlook the obvious. But in all other programming languages that I know and that have associative arrays, or hashes, the elements in...
3
by: Robert Mark Bram | last post by:
Hi all, I have some code to iterate through nested associative arrays. Can anyone please tell me what I am doing wrong? :) var dealers = new Array(); var dealer1 = new Array(); dealer1 =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.