Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I specify the 'name' of each array element?

Status
Not open for further replies.

JGKWORK

IS-IT--Management
Apr 1, 2003
342
GB
Hi, can any1 show me how to do the vbscript equivelant of this Javascript:

var postcodereferral = new Object()

postcodereferral"AL5 3" = "S"
postcodereferral"AL5 4" = "S"
postcodereferral"AL9 6" = "S"

or just a way that I can specify the 'name' of each array element.

Many thanks.
 
I thought there might be an easier way, I have never used multi dimensional arrays before. Thanks anyway.

What I'm doing at the moment is creating an array with 10 elements, but only referencing 5 of them (numbers 5-10) because those are the numbers I passing in to the page. But this is cheating and I want to find the correct way!

Ta.
 
You need to use Scripting.Dictionary object and should work.

Set d = CreateObject("Scripting.Dictionary")
Set c = CreateObject("Scripting.Dictionary")
d.Add "AL5 2","s"
d.Add "AL5 3",Array("100","test","another value")
c.Add "name","george"
d.Add "AL5 4",c
you can access

d("AL5 3") it's the Array("100","test","another value")
d("AL5 2") it's "s"
d("AL5 4") it's c object
d("AL5 3")(0) should be "100" and so on
d("AL5 4")("name") it's "george"


________
George, M
 
Hi, thanks for the help, unfortunately i keep geting the " d does not support this property or method. Here is what i have written:

<%
set d = CreateObject(&quot;Scripting.Dictionary&quot;)

d.Add &quot;1&quot;,&quot;No 6: Generators <br> next line&quot;
d.Add &quot;2&quot;,&quot;No 7: Lighting Sets <br> next line&quot;
d.Add &quot;3&quot;,&quot;No 8: Piling <br> next line&quot;

d(&quot;1&quot;)

%>

thanks.
 
ok, got it working - thanks alot shaddow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top