2009年2月03日10:23上午
51Testing软件测试网i.W4_3mQ2ZND'The scrīpt for Preparing the
test data,and saving it as .txt file.
51Testing软件测试网6\[r(yr5Z51Testing软件测试网 fXj*MoOption Explicit
#Ex-mPPY!]0On Error Resume next
(X5f wb_*gNs4A4E+u w051Testing软件测试网8dXd K3RDim fileName,path,line,fso,choice,file,i
1t@6zVx,D
Gc U4i/tC051Testing软件测试网jb-e(P2?g{+CK'path means the location of the file
5@
j2]va{0path = "C:\Documents and Settings\Administrator\My Documents\"
WU3\~r6e"e4U1S7F0'fileName means the name of the test file
p/h MSKZ
x6LT0fileName = "testData.txt"
2A6^.U6bbG-F%`E(Nz2P0'line and colum below mean the line Number and the colum Number of the test data
51Testing软件测试网k\f9m|yline = 10
2FHb[!K$XRqB5q0ra051Testing软件测试网];\%x*uzS)grn.dSet fso = Wscrīpt.CreateObject("scrīpting.filesystemobject")
51Testing软件测试网y$d/H]r2k2V4D:g8n&S9L\ zd0'Check whether the file exists or not.If not exist, create the file.
0O+SZ8pM T0If fso.FileExists(path&fileName) Then
51Testing软件测试网6Z5jY1KCP!mO choice = InputBox("Please choose your choice: "_
51Testing软件测试网'Ob+F2l9kw_bH Q/l &"1 Stop the scrīpt "_
51Testing软件测试网"G'c\d/Uf N+OoS &"2 Overwrite the file "_
"Lu,Ec*N0 &"3 Append to the end of file")
51Testing软件测试网O`2i&qlaG~K Select Case choice
51Testing软件测试网f$?xN&R2jr Case "1": MsgBox "Stop the scrīpt",,"Prompt"
|9]7z0{'FW \0 Wscrīpt.Quit
#^
ID#J;xl{W0 Case "2": Set file = fso.OpenTextFile(path&fileName,2)
51Testing软件测试网6voh tY(Qb/Q
a Case "3": Set file = fso.OpenTextFile(path&fileName,8)
(~ Ip.gH!s0 Case Else: MsgBox "Your choice is invalid.The scrīpt stops.",,"Prompt"
51Testing软件测试网$z'h%yE+G!l Wscrīpt.Quit
51Testing软件测试网;b/?rva`b8P{y End Select
51Testing软件测试网:^
n5^w?'S5v%gyeRElse Set file = fso.CreateTextFile(path&fileName,2,true)
51Testing软件测试网W"`*j(m k[j r@0XeEnd if
'iJ@]%Nz051Testing软件测试网D^a,R(J2ow;w:a-aU'Write Colum Name
$W Cxq0c0file.Write("UserName")
51Testing软件测试网l5b{"\?+y$b_F/}file.Write(" ")
]k$ssa4`9w0file.Write("Password")
51Testing软件测试网Z_!o6I8h2yfile.WriteLine(1)
51Testing软件测试网Z^d#P%V3e*H@51Testing软件测试网` {+Q ~ F@'Write test data
51Testing软件测试网0msACSb~_p-H9zFor i=0 To line
#}_'Z/OY(_0 file.Write("TuserName"&i)
Mk.?rGbm5O*_0 file.Write(" ")
^fE4Y4jiK-ju0 file.Write("TPwd"&i)
51Testing软件测试网8fo#Ck#Oa6m5Dg)d file.WriteBlankLines(1)
51Testing软件测试网KN]j;iNext
51Testing软件测试网Do/RlZ R2T
Nf(Y:Q/z&tm&a5e0'Close the file
]'Go {2Yu0file.Close
JH WF5_NX |!MWc051Testing软件测试网%j;l2}3dE5Etpf$}KSet fso = nothing
#T!UC6| i&Nx&|0