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 Explicit
51Testing软件测试网7Y"U
D_Ug~pOn 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 file
51Testing软件测试网
RZ'ia,C_5ztypath = "C:\Documents and Settings\Administrator\My Documents\"
Z c`#t{c3y@0'fileName means the name of the test file
| vqpZx?+Fp0fileName = "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 = 10
51Testing软件测试网uGR{N*nqdQ*tK8@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"
QJQguP0 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.Quit
51Testing软件测试网9K!?7y)Slzz bJ End Select
51Testing软件测试网|3oMj"LK&{Else Set file = fso.CreateTextFile(path&fileName,2,true)
`:o2M;J A+M0End if
51Testing软件测试网v0T^3_X#t-w51Testing软件测试网,y@Rxl~g'Write Colum Name
51Testing软件测试网*DFk]r&Kfile.Write("UserName")
&Wnsz ?~ P!]sr9Y0file.Write(" ")
51Testing软件测试网K |ea$CPMi$Gfile.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/N8wqTA0V8UC0 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#INext
e5H(svgK051Testing软件测试网
h)PYbb'Close the file
51Testing软件测试网ZP{3BA
v6zfile.Close
)X,g]
Hl2fip8a051Testing软件测试网c8[V8z$C@o!u[Set fso = nothing
|6S6l(LwK0