51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1472|回复: 0
打印 上一主题 下一主题

QuickTest Professional :Random Name Generator

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2006-10-30 14:20:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Description

      How to generate random names at run time?


Solution

      This code will generate how much ever random names you need.

Steps :

#1
Attach the RandomPicker.vbs to your test first.

#2
Add this code to your test :

' ***********************
Dim nCnt

nCnt = Inputbox("Enter the number of Names needed")

RandomPicker(nCnt)

arrName = split(rName,",")

For i = 1 to nCnt - 1

Msgbox arrName(i)

Next

' ***********************


#3
Try running the test.



This code will generate the random names that you give as input in the InputBox.
Note : You can also add some validation to restrict the number of value in InputBox.


vbs code:


Dim  rName, rInt

Public Sub RandomPicker(rCnt)

        rName = "SANJAY"

        For rInt = 1 To rCnt

                ' Picking up seconds of current time                                                                                                                                                                                                                                  
                aVal = time
                arrVal = split(aVal,":")
                aVal = arrVal(2)
                aVal = left(aVal,2)
                 
                ' Picking up date of current date                                                                                                                                                                                                                                  
                bVal = date
                arrVal = split(bVal,"/")
                bVal = arrVal(0)
               
                ' Manuplating it to Generate Random Number
                cVal = aVal + bVal
                dVal = aVal * bVal
                zVal = cVal * dVal
                fVal = left(zVal,2)
                gVal = right(zVal,2)
                fVal = fVal + rInt
                 gVal = gVal + rInt
                                          
                If rInt Mod 2 = 0 Then
                         
                         ' Set of Different combination of words stored in an array
                         One = array("AZK","AJJ","AZD","AZC","AZB","QNW","QNX","AZV","AZU","AZT","AZS","QNN","QNO","QNP","QNQ","AZN","AZM","AZR","AZQ","QNI","QNJ","QNK","KPG","KPH","KPI","KPJ","KPM","KPN","KPO","KPU","KPV","KPW","KPX","KPY","KPZ","OLA","OLB","OLC","OLD","OLX","OLY","OLZ","QNA","QNB","QNC","QND","QNE","QNF","QNG","QNH","AZL","QNY","AZY","AZX","AZW","QNR","QNS","AZH","AZG","AZF","AZE","AZP","AZO","QNL","QNM","KPA","KPT","OLE","OLF","OLG","OLH","OLI","OLJ","OLK","OLL","OLM","OLN","OLO","KPB","KPC","KPD","KPE","KPF","KPP","KPQ","KPR","KPS","AZA","AZZ","QNT","QNU","QNV","OLR","OLS","OLT","OLU","OLV","OLW","KPK","KPL","QNZ","AZI","OLP","OLQ")
                         iVal = One(fVal)
                         
                         Two = array("KPB","KPC","KPD","KPE","KPF","KPP","KPQ","KPR","KPS","AZA","AZZ","QNT","QNU","QNV","OLR","OLS","OLT","OLU","OLV","OLW","KPK","KPL","QNZ","AZI","OLP","OLQ","AZY","AZX","AZW","QNR","QNS","AZH","AZG","AZF","AZE","AZP","AZO","QNL","QNM","KPA","KPT","OLE","OLF","OLG","OLH","OLI","OLJ","OLK","OLL","OLM","OLN","OLO","KPM","KPN","KPO","KPU","KPV","KPW","KPX","KPY","KPZ","OLA","OLB","OLC","OLD","OLX","OLY","OLZ","QNA","QNB","QNC","QND","QNE","QNF","QNG","QNH","AZL","QNY","AZK","AJJ","AZD","AZC","AZB","QNW","QNX","AZV","AZU","AZT","AZS","QNN","QNO","QNP","QNQ","AZN","AZM","AZR","AZQ","QNI","QNJ","QNK","KPG","KPH","KPI","KPJ")
                         jVal = Two(gVal)
                         
                Else
                         
                         Three = array("AZY","AZX","AZW","QNR","QNS","AZH","AZG","AZF","AZE","AZP","AZO","QNL","QNM","KPA","KPT","OLE","OLF","OLG","OLH","OLI","OLJ","OLK","OLL","OLM","OLN","OLO","AZK","AJJ","AZD","AZC","AZB","QNW","QNX","AZV","AZU","AZT","AZS","QNN","QNO","QNP","QNQ","AZN","AZM","AZR","AZQ","QNI","QNJ","QNK","KPG","KPH","KPI","KPJ","KPM","KPN","KPO","KPU","KPV","KPW","KPX","KPY","KPZ","OLA","OLB","OLC","OLD","OLX","OLY","OLZ","QNA","QNB","QNC","QND","QNE","QNF","QNG","QNH","AZL","QNY","KPB","KPC","KPD","KPE","KPF","KPP","KPQ","KPR","KPS","AZA","AZZ","QNT","QNU","QNV","OLR","OLS","OLT","OLU","OLV","OLW","KPK","KPL","QNZ","AZI","OLP","OLQ")
                         iVal = Three(fVal)
                         
                         Four = array("KPM","KPN","KPO","KPU","KPV","KPW","KPX","KPY","KPZ","OLA","OLB","OLC","OLD","OLX","OLY","OLZ","QNA","QNB","QNC","QND","QNE","QNF","QNG","QNH","AZL","QNY","AZY","AZX","AZW","QNR","QNS","AZH","AZG","AZF","AZE","AZP","AZO","QNL","QNM","KPA","KPT","OLE","OLF","OLG","OLH","OLI","OLJ","OLK","OLL","OLM","OLN","OLO","KPB","KPC","KPD","KPE","KPF","KPP","KPQ","KPR","KPS","AZA","AZZ","QNT","QNU","QNV","OLR","OLS","OLT","OLU","OLV","OLW","KPK","KPL","QNZ","AZI","OLP","OLQ","AZK","AJJ","AZD","AZC","AZB","QNW","QNX","AZV","AZU","AZT","AZS","QNN","QNO","QNP","QNQ","AZN","AZM","AZR","AZQ","QNI","QNJ","QNK","KPG","KPH","KPI","KPJ")
                         jVal = Four(gVal)
                         
                End If
                          
                kVal = iVal & jVal
                         
                If rName="SANJAY" Then
                         
                         rName = kVal
                       
                Else
                         
                         rName = rName + "," + kVal
                               
                End If
                         
                         
        Next                         
       
End Sub
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-11-24 03:18 , Processed in 0.066511 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表