Micro Focus QTP (UFT) Forums
Need a logic in array - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Need a logic in array - QTP (/Thread-Need-a-logic-in-array-QTP)



Need a logic in array - QTP - surestud - 05-06-2015

Hi Guys,

I need your help for below logic
i Have a array which stores text values of radio button to choose in my application and another array of values which has to be choosed based on first array values.consider the below examples
Array A = {1;2;3}
Array B = {x,y,z;a,b;v,f,g,h}

From the above arrays, i need to select 1 radio button and once its gets selected i need to select its associated values like x&y&z, same for 2 with a,b and 3 with v,f,g,h

could you pls help in this? can you give me the script for it..

Thanks & hoping will get soon a solution for this


RE: Need a logic in array - QTP - GSAT - 06-24-2015

Tagging myself in for a similar query.


RE: Need a logic in array - QTP - kbhargava505 - 07-31-2015

Could you give some more realistic information about your problem, we can try to give best?

With the data you've given we can simply writes the code using select case statement.


RE: Need a logic in array - QTP - sporandla - 07-31-2015

Please find the code.
Array A = {1;2;3}
Array B = {x,y,z;a,b;v,f,g,h}

Code:
sFirstArraySpilt = Split(A,";")
sSecondArraySplit = Split(B,";")
For I=0 to UBOUND(sFirstArraySpilt)
sSecondArrayValues = sSecondArraySplit(I)
'Here sSecondArrayValues contains the values separated with commas ex: x,y,z for the first value in Array A
Next



RE: Need a logic in array - QTP - cuongtv - 08-20-2015

Code:
'make sure A & B having the same number of elements
Dim arrA,arrB,arrsubB
Dim val
arrA = Split(A,";")
arrB = Split(B,";")
For i = 0 to Ubound (arrA) Step 1
    arrsubB = Split(arrB(i),",")
    For j = 0 to UBound(arrsubB) Step 1
        val = arrsubB(j)
        'Do with each of your value, example: x,y,z
    Next
Next