Micro Focus QTP (UFT) Forums
Generating Random number - 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 Regular Expressions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Regular-Expressions)
+--- Thread: Generating Random number (/Thread-Generating-Random-number)



Generating Random number - be_sure - 09-30-2008

Hello,
I am here with the hope of finding the syntax for generating the 10 digit random number to be stored in the global data sheet, so that it could be used some where else in the action. But next time when we run the same scrpt it should give other random number. I hope u understand.
Thanks for your help and time. Smile


RE: Generating Random number - VENKATAREDDY_M - 09-30-2008

Hi,

Use below Syntax.

Code:
iRandomValue = RandomNumber(1000000000,9999999999)

It will Generate a 10 Digit Random Value Exery time.

Other ways, you can write a Function with Length as Parameter which will Return a Random Value of your desired length.

The first one will be the easiest solution for you.

Hope this info will help you


Thanks

VENKATA


RE: Generating Random number - kishoreinchennai - 09-30-2008

Code:
Randomize
Environment.Value("Client_No_Random")=Int((maxvalue - minvalue + 1) * Rnd) + minvalue

Randomize will make it to return a different number after every run ....

regards


RE: Generating Random number - be_sure - 10-03-2008

Thank you very much VenkatReddy garu and Chennai Kishore garu.... both of your ideas were very useful for me.