Search This Blog

Welcome to Machers Blog

Blogging the world of Technology and Testing which help people to build their career.

Wednesday, December 16, 2009

Working with Arraylist of Dot Net in Qtp's VbScript

Set array1 = CreateObject( "System.Collections.ArrayList" )

Set array2 = CreateObject( "System.Collections.ArrayList" )



Private Sub PrintInfo( ByVal title )

dim str

str="title" & vbNewLine

str1= "array1 Capacity = " & array1.Capacity & vbcrlf

str2= "array2 Capacity = " & array2.Capacity & vbcrlf

str3= "array1 Count = " & array1.Count & vbcrlf

str4= "array2 Count = " & array2.Count & vbcrlf

str5= "array1 IsFixedSize = " & array1.IsFixedSize & vbcrlf

str6= "array2 IsFixedSize = " & array2.IsFixedSize & vbcrlf

str7= String( 50, "*" ) & vbcrlf

Msgbox str & str1 & str2 &str3 & str4 & str5 & str6 & str7

End Sub

array2.Capacity = 10

Call PrintInfo( "Before adding items." )

' ** Adding an item to arrays

array1.Add "New York" : array2.Add "New York"

Call PrintInfo( "After adding 1 item." )

array1.Add "Boston" : array2.Add "Boston"

array1.Add "Dallas" : array2.Add "Dallas"

array1.Add "Chicago" : array2.Add "Chicago"

Call PrintInfo( "After adding 3 more items" )

array1.Remove( "Boston" )

Call PrintInfo( "After removing 1 item form array1" )

1 comment:

STC Technologies said...

I'm actively using DotNetFactory with QTP, and am having difficulty returning arrays to QTP from methods I've created in .NET. In some cases I really want to be able to return an array of objects, but even simple data type arrays are not working. For simple data types I'm getting a string value indicating the method return type.STC Technologies|STC Technologies