Micro Focus QTP (UFT) Forums
Working with array - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Working with array (/Thread-Working-with-array)



Working with array - excellentpawan - 06-30-2013

i created following code to split with delimetre "," now i want to store output in an array please help how to do

Code:
Dim out, svar
svar = "1,a;2,b;3,c;4,d;5,e"
out = split(svar,",")
For each i in out
    print i
Next



RE: Working with array - supputuri - 06-30-2013

your split output itself is an array. Refer to VBScripting basics or QTP helper guide.

in the above code ''out" is an array.


RE: Working with array - excellentpawan - 06-30-2013

hi supputuri thanks for reply I know this is array but i want to store all elements after "," in an array and elements after ";" in another array


RE: Working with array - Ankur - 06-30-2013

Your two arrays would be arr1 and arr2 below -

Code:
Dim svar, out, arr, arr1, arr2
svar = "1,a;2,b;3,c;4,d;5,e"
out = split(svar,";")

ReDim arr1(UBound(out))
ReDim arr2(UBound(out))

For i = 0 To UBound(out)

arr = split(out(i),",")

    arr1(i) = arr(0)
    arr2(i) = arr(1)
    
Next

@all : I'm sure there must be some better solution to this, please try and put it here.