Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A DotnetFactory question on Stacks
#1
When I run the following code as a vbs file, it executes as expected.

Code:
Set objStack = CreateObject("System.Collections.Stack") 'Set objStack = DotNetFactory.CreateInstance("System.Collections.Stack") ''Adding elements in Stack objStack.Push "Item_1" objStack.Push "Item_2" objStack.Push "Item_3" objStack.Push "Item_4" ' 'Iterate through each element of Stack For Each Itm In objStack 'Print Item msgbox Itm Next msgbox "stack count = " & stack.count ' 'Convert Stack to Array 'Print Join(objStack.ToArray, ",") ' 'output: Item_4,Item_3,Item_2,Item_1 msgbox Join(objStack.ToArray, ",")

When I execute the script in QTP by altering the comment lines, I am informed that the object in the line "For Each Itm in objStack" is not a collection.
Also in QTP, for the "Join" line, the error message is "Type mismatch: 'Join' "

What am I doing wrong? Do I need to somehow use ICollection?
I guess part of my expectation has been if dotnet could be written in VBscript, then changing "CreateObject" to "DotNetFactory.CreateInstance" and presto, the code would execute.

Thanks for any and all help,

Parke
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to read registry values using DotNetFactory in QTP mag 0 3,764 07-16-2008, 06:36 PM
Last Post: mag

Forum Jump:


Users browsing this thread: 1 Guest(s)