Micro Focus QTP (UFT) Forums
Find 1 4 10 22 - 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: Find 1 4 10 22 (/Thread-Find-1-4-10-22)



Find 1 4 10 22 - vasu - 12-08-2011

how to find the these numbers by using vb scripting(by using for loop)

pls answer me



Thanks
vasu.SmileSmileSmile


RE: Find 1 4 10 22 - ravi.gajul - 12-08-2011

where do you want to find these numbers from?
1)From a group of numbers?
2)From string?

Can you please elaborate?


RE: Find 1 4 10 22 - PrabhatN - 12-14-2011

Hi Vasu,

If i have correctly understood the sequence, it is in the form of n=n*2+2, n starting from 1. The following code will yield this sequence

Code:
Dim arr(10) //Declare an array which will contain the sequence numbers
totNum=4 // Total number in the sequence (here 4 since seq is 1 4 10 22)
arr(0) = 1 //Assign the first place with value 1

For counter=1 To totNum
    arr(counter) = arr(counter-1)*2+2
Next

The array should contain the sequence.