Defining Arrays in VBScript

Results 1 to 5 of 5

Thread: Defining Arrays in VBScript

  1. #1
    Join Date
    Dec 1969
    Posts
    109

    Default Defining Arrays in VBScript

    Can I define an array in VBScript in one statement instead of<BR>populating each element manually.<BR><BR>e.g. instead of this<BR>Dim MyArray(2)<BR>MyArray(0) = "Red"<BR>MyArray(1) = "Green"<BR>MyArray(2) = "Blue"<BR><BR>I want to do something LIKE this:<BR>Dim MyArray(2)<BR>MyArray = ("Red", "Green", "Blue")<BR><BR>Is it possible and what is the syntax?<BR><BR>Thanks!<BR><BR><BR>Oliver<BR>oliver @3waystreet.com

  2. #2
    Join Date
    Dec 1969
    Posts
    73

    Default RE: Defining Arrays in VBScript

    http://www.4guysfromrolla.com/webtech/012799-3.shtml<BR><BR>This article will show you how to start.<BR>

  3. #3
    Join Date
    Dec 1969
    Posts
    109

    Default RE: Defining Arrays in VBScript

    I don&#039t think my question is that complicated. Sure, I could<BR>write a function to populate an array however I liked but<BR>before I do that, I was wondering if there&#039s a built in way to<BR>define an array in one statement. I just think it looks ugly to<BR>define each element on one line, especially if I have a 50 element array.<BR><BR><BR>Oliver

  4. #4
    Join Date
    Dec 1969
    Posts
    23

    Default RE: Defining Arrays in VBScript

    Dim MyArray<BR>MyArray = Array("Red", "Green", "Blue", 2, 3)<BR><BR>Good Luck!


  5. #5
    Join Date
    Dec 1969
    Posts
    109

    Default RE: Defining Arrays in VBScript

    Thanks Tester! Question: what do the 2 and the 3 signify?<BR>I&#039m guessing 3 for 3 elements. But 2? 2 dimensional array?<BR>This example is 1 dimensional, no?!<BR><BR><BR>Oliver

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •