Micro Focus QTP (UFT) Forums
Unable to use array in QTP - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Unable to use array in QTP (/Thread-Unable-to-use-array-in-QTP)



Unable to use array in QTP - amit25007 - 01-25-2016

Hello,

I have converted a string into an array using below function.

Function SpliteStringToArray(mystring, delimiter, outputArray)

    myArray = split(mystring, delimiter)

    For i = Lbound(myArray) to Ubound(myArray)
      outputArray = myArray(i)
    Next

End Function


But after calling the function, i am not able to use the outputArray.

Call SpliteStringToArray("amit/qtp", "/", Array1)
print Array1(1)

It gived error as type mismatch.
Please help


Regards
Amit


RE: Unable to use array in QTP - ovidiu - 01-25-2016

Example of use:

Dim arrayList
Call SpliteStringToArray("1,2,3,4,5"",", arrayList)
For i = Lbound(arrayList) to Ubound(arrayList)
    msgbox(arrayList(i))
Next


Public Function SpliteStringToArray(mystring, delimiter, outputArray)

    myArray = split(mystring, delimiter)

    ReDim outputArray(Ubound(myArray))
    outputArray = myArray

End Function


RE: Unable to use array in QTP - amit25007 - 01-25-2016

Hello ovidiu,

Thanks a lot.
Its working now.



Regards
Amit