mst1
11 years agoOccasional Contributor
For Each not working with dotNET.system_collections.ArrayList in vbScript
Hello, I want to use an ArrayList object from the system.collections library, because of it's great member functionallities. However, when I create such an object as next , I am not able...
- 11 years ago
Hi Frank, I did a quick bit of research and came up with a theory
CreateObject creates and returns a reference to a COM object
For Each is a VBScript construct
If you inspect myList when it is created using CreateObject, you can view cannot view any properties and methods
If you inspect myList when it is created using dotNET.System_Collections.ArrayList.zctor, you view all properties, fields and methods
My conclusion is that CreateObject and dotNET.System_Collections.ArrayList.zctor create different types of objects and the VBScript For Each construct can only operate on a COM object created by using CreateObject
dotNET.System_Collections.ArrayList.zctor probably creates an instance of a .Net object in which certain operations are not available to native VB Script
This appears to be confirmed as if you use CreateObject to create myList, myList.ToArray will fail whereas if you use dotNET.System_Collections.ArrayList.zctor it will work
Regards,
Phil Baird