声明:本空间的内容不全部是原创,如有雷同只为学习与借鉴之方便,别无它意,来者是朋友,愿通过此平台结交天下测试达狼!
Close、Write、WriteLine及WriteBlankLines的使用
上一篇 /
下一篇 2010-05-14 13:59:07
/ 个人分类:QTP
Dim strPath,strText51Testing软件测试网uCKF'o!r
strPath = "C:\type.txt"
M5K_"tXc0RP8X ql0strText = "This is Test !"& vbCrLf & “hello word !” '这块报语法错误--EXPECTED EXPRESSION!
K,jC(kG3Z0pm0'调用函数
8p}PS
z2Hs0Call CreateFile(strPath,strText)
5| K
^|8xc0Sub CreateFile(strPath,strText)51Testing软件测试网.mu"p_&P`F
Dim objFso,objStream51Testing软件测试网i JWTb Zj`
'创建FileSystemObject对象51Testing软件测试网a0x{7]7`
Set bjFso = CreateObject("Scripting.FileSystemObject")51Testing软件测试网1\?xDE
'使用FileSystemObject对象的CreateTextFile(),来返回一个TextStream对象句柄
Z6\z"xbeF0 Set bjStream = objFso.CreateTextFile(strPath,True)51Testing软件测试网qb%oHxY
'三个Write的意思分别为:在文本中写入字符、写入带换行符的字符、写入3个换行符
}_4H8r,_Oh0i-NL8l-c e0 objStream.Write(strText)
.{2yWY:ab;LW0 'objStream.WriteLine(strText)51Testing软件测试网X9m{I*F#Q4hs
'objStream. WriteBlankLines 351Testing软件测试网%T"F+D\]9y
'关闭TextStream对象51Testing软件测试网qS6G F!`D
XWB \
objStream.Close
,s}_+YZ}^*@xA2X0End Sub
X f'Wkve(s0把这块
Dim strPath,strText
,T
W]@,{Q3s n0strPath = "C:\type.txt"51Testing软件测试网zgMb5AM4cxRm*V5I Q
strText = "This is Test !"& vbCrLf & “hello word !”
修改成
Dim strPath,strText,a,b
R LJ2e
e1M6Kg-j:\~{O[0strPath = "C:\TYPE.txt"
6a)p s:l/]
t-K:sY0 a= "This is Test !"
~q|ddn0 b="hello world!"
[]%s sW+C0 strText= a&vbcr &b
问题就解决了
收藏
举报
TAG: