Re: Arrays in VBScript

From: Roland Hall (nobody_at_nowhere)
Date: 05/31/04


Date: Mon, 31 May 2004 05:51:32 -0500


"Bob" wrote in message news:155a301c446b7$60d3a8a0$a401280a@phx.gbl...
: Unlike VBScript, the arrays in Javascript are objects that
: have methods and properties. The following example defines
: an array in Javascript. How can I achieve the same in
: VBScript? Can someone convert the following function
: (arrayTest ()) defined in Javasctipt to its equivalent in
: VBScript and/or in VB6?
:
: To understand the function, create an HTML file with the
: following and open the file:
:
: Thanks in advance,
: Bob
:
: <html>
: <head>
: <script language="javascript">
: function arrayTest()
: {
: var i;
: symbols = [{person:"Bob", age:"26",
: gender:"male"}, {person:"Amy", age:"23",
: gender:"female"}]
:
: alert(symbols.length);
: for (i=0; i<symbols.length; i++)
: {
: alert(symbols[i].person);
: alert(symbols[i].age);
: alert(symbols[i].gender);
: }
: }
: </script>
: </head>
: <body onload="arrayTest()">
: Testing for Arrays in javascript
: </body>
: </html>

Hi Bob...

This appears to be an associative array. VBScript has associative arrays,
called dictionaries but, AFAIK, they cannot be indexed so this might be a
little more difficult. There may be a better alternative. My example
requires a unique format of the data to follow your theme.

I didn't put this in ASP so it requires IE to run it.
http://kiddanger.com/lab/bob/arrays.html

HTH...

-- 
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp


Relevant Pages

  • Object instead of array? Any problems?
    ... Javascript isn't my specialty, ... TONS of arrays, and I'm using vbscript to actually build them into the ... lol - it's a mess. ...
    (comp.lang.javascript)
  • Arrays in VB6
    ... Unlike VBScript, the arrays in Javascript are objects that ... an array in Javascript. ... create an HTML file with the ... Testing for Arrays in javascript ...
    (microsoft.public.vb.syntax)
  • Arrays in VBScript
    ... Unlike VBScript, the arrays in Javascript are objects that ... an array in Javascript. ... create an HTML file with the ... Testing for Arrays in javascript ...
    (microsoft.public.scripting.vbscript)
  • Arrays in VB6
    ... Unlike VBScript, the arrays in Javascript are objects that ... an array in Javascript. ... create an HTML file with the ... Testing for Arrays in javascript ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Using AJAX/JSON and performance issues with eval()
    ... evalevaluates its string argument as an ECMAScript ... JS arrays are implemented as objects, ... multiple HTML tables automatically in the background) and really want it ... Prototype.js was written by people who don't know javascript for people ...
    (comp.lang.javascript)