QTP/UFT: Generate Alphanumeric and Random Number


”’## 3 digits Random idNumber and 7 digits Random serialNumber
    Dim start, ends
    start = 1
    ends = 19
    For m = start To ends
        idNumber = RandomNumber (111919)
        serialNumber = RandomNumber (11119991119999)
    Next

”## Generate Alphanumeric Number
Function generateAlphanumeric(StrLen)
Dim alpNumStr
Const MainStr= “0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ”
For i = 1 to StrLen
  alpNumStr=alpNumStr & Mid(MainStr,RandomNumber(1Len(MainStr)),1)
Next
generateAlphanumeric = alpNumStr
End Function
”## 3 digits Alphanumeric Number
serialNum = generateAlphanumeric(3)

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s