Lists in VBScript

后端 未结 3 1937
孤独总比滥情好
孤独总比滥情好 2020-12-03 10:36

I\'m trying to create a simple list in a VBscript, but I\'m unable to find something similar.

Basically, I\'m working on Active directory, and I need to get all the

3条回答
  •  没有蜡笔的小新
    2020-12-03 11:11

    Get rid of the dictionary and unleash the power of an ArrayList.

    Option Explicit
    
    dim list
    Set list = CreateObject("System.Collections.ArrayList")
    list.Add "Banana"
    list.Add "Apple"
    list.Add "Pear"
    
    list.Sort
    list.Reverse
    
    wscript.echo list.Count                 ' --> 3
    wscript.echo list.Item(0)               ' --> Pear
    wscript.echo list.IndexOf("Apple", 0)   ' --> 2
    wscript.echo join(list.ToArray(), ", ") ' --> Pear, Banana, Apple
    

    EDIT: I see you already tried the ArrayList, but got an error. It seems your installation of the dotnet framework is not correct (System.Collections.ArrayList is part of that). Microsoft has an article about how to solve that: http://answers.microsoft.com/en-us/windows/forum/windows_7-performance/error-code-0x80131700/3add8d80-00e0-4355-a994-8630d01c18f5

提交回复
热议问题