QA automation with QTP/UFT – simple function for creating a random value based on a provided range

Hi. Today is going to be a very quick post. Here's a great function which gives you a random number based on your provided range.

Function funRandomNumberWithinRange(intMinimumNo, intMaximumNo)
funRandomNumberWithinRange = Int(((intMaximumNo - intMinimumNo) * Rnd) + intMinimumNo)
End Function

To use this function, simply call it along with a specific range:

MsgBox fnRandomNumberWithinRange(1, 10)

This will give you a number between 1 and 10! Awesome right? Leave your questions and feedback below!

Pin It on Pinterest

Clef two-factor authentication