Micro Focus QTP (UFT) Forums
Create a random number starting with an alphabet - 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: Create a random number starting with an alphabet (/Thread-Create-a-random-number-starting-with-an-alphabet)



Create a random number starting with an alphabet - QTPmate - 07-15-2014

Hi,
Could any one help me to create a random number starting with alphabet like A123456,

Regards.


RE: Create a random number starting with an alphabet - Ankesh - 07-24-2014

Hi,

does the alpahbet remain consant or it is random as the numbers?


RE: Create a random number starting with an alphabet - QTPmate - 07-30-2014

Hi Ankesh,

Thanks for your time and reply to the post.
Alphabet will be changing as well. I would like to select from an array of 10 alphabets.

Regards.


RE: Create a random number starting with an alphabet - gangadhar - 07-30-2014

Hi QTPmate,

Its simple.You can do it in a couple of ways.I am just presenting the logic.

For alphabets you would be getting it from Array so no problem for that.

For numbers what you can do is , you can use vbscript "Time" function which would return 3:26:54 , which you can split using ":" as delimiter , get it in array , then append array(0) , array(1) , which would give you a random number.

Here is the code which you can change accordingly

Code:
str_randomno=Time
Dim aftersplitting
aftersplitting=split(str_randomno,":")
print aftersplitting(0)&aftersplitting(1)&left(aftersplitting(2),2)

Thanks,
Gangadhar


RE: Create a random number starting with an alphabet - QTPmate - 07-31-2014

Thanks for help Gangadhar appreciated.