与其临渊羡鱼,不如退而结网!

VBS(二)——Script for Preparing the test data

上一篇 / 下一篇  2009-02-03 10:47:33 / 个人分类:其他

2009年2月03日10:23上午51Testing软件测试网1N!~&oY+X;n8|B
'The scrīpt for Preparing the test data,and saving it as .txt file.
*XY \9?-jHNF:t0
cdqT9Hj:Q0Option Explicit51Testing软件测试网7Y"U D_Ug~ p
On Error Resume next
L(eU G$SQ |0
R:{V6S9pAJM0Dim fileName,path,line,fso,choice,file,i
`6U9}h4N9Zs051Testing软件测试网#i%QzQEs
'path means the location of the file51Testing软件测试网 RZ'ia,C_5zty
path = "C:\Documents and Settings\Administrator\My Documents\"
Z c`#t{c3y@0'fileName means the name of the test file
|vqpZx?+F p0fileName = "testData.txt"
7ppck(y4G+p+f#i0'line and colum below mean the line Number and the colum  Number of the test data
Z3kR8iT(e4i0I0line = 1051Testing软件测试网uGR{N*nqdQ*tK

8@c~#M'W;^}PP0Set fso = Wscrīpt.CreateObject("scrīpting.filesystemobject")51Testing软件测试网Ry y!qoG1u4|

1c.GXR lS:e+q0'Check whether the file exists or not.If not exist, create the file.
9q1Xm8N [ LGm0If fso.FileExists(path&fileName) Then
@n%AP| Wri,O0        choice = InputBox("Please choose your choice:        "_
Q mT T!q ~0                    &"1    Stop the scrīpt            "_51Testing软件测试网,ZK nhB1U6X\8}
                    &"2    Overwrite the file        "_
-o zs U6x"BH.C w0                    &"3    Append to the end of file")
dZU({6z)H0    Select Case choice
:BYV5Tup%rJ0        Case "1": MsgBox "Stop the scrīpt",,"Prompt"
QJQgu P0                Wscrīpt.Quit
k)\ y3t|P$Id8S'G0        Case "2": Set file = fso.OpenTextFile(path&fileName,2)
Ja,voZIc2W0        Case "3": Set file = fso.OpenTextFile(path&fileName,8)51Testing软件测试网'u(Q%C$kU9P/Q4z6ux2[)]
        Case Else:  MsgBox "Your choice is invalid.The scrīpt stops.",,"Prompt"51Testing软件测试网8gFG+MbS@#M%~
                    Wscrīpt.Quit51Testing软件测试网9K!?7y)SlzzbJ
    End Select51Testing软件测试网|3oMj"LK&{
Else Set file = fso.CreateTextFile(path&fileName,2,true)   
`:o2M;J A+M0End if51Testing软件测试网v0T^3_X#t-w
51Testing软件测试网,y@R xl~g
'Write Colum Name51Testing软件测试网*DFk]r&K
file.Write("UserName")
&Wns z?~P!]sr9Y0file.Write("    ")51Testing软件测试网K |ea$CPMi$G
file.Write("Password")
0Skr dT'b@7P&x0file.WriteLine(1)51Testing软件测试网;]DsX(_

B-o \N2a8Tw EbF0'Write test data
8H9a%z$J$t)v B0For i=0 To line
#KK/N8wqTA0V8U C0    file.Write("TuserName"&i)51Testing软件测试网1xrf{$BI o
    file.Write("    ")51Testing软件测试网4ejb.l9y PR
    file.Write("TPwd"&i)51Testing软件测试网p6LbH5t\$@6^
    file.WriteBlankLines(1)51Testing软件测试网pd:[exKw#I
Next
e5H(svgK051Testing软件测试网 h)PYbb
'Close the file51Testing软件测试网Z P{3BA v6z
file.Close
)X,g] Hl2fip8a051Testing软件测试网c8[V8z$C@o!u[
Set fso = nothing
|6S6l(LwK0

TAG: 其他

 

评分:0

我来说两句

Open Toolbar