声明:本空间的内容不全部是原创,如有雷同只为学习与借鉴之方便,别无它意,来者是朋友,愿通过此平台结交天下测试达狼!
Close、Write、WriteLine及WriteBlankLines的使用
上一篇 /
下一篇 2010-05-14 13:59:07
/ 个人分类:QTP
Dim strPath,strText51Testing软件测试网sKLCYKQL*q.?j
strPath = "C:\type.txt"
[:oq(Sfh6f
phL0strText = "This is Test !"& vbCrLf & “hello word !” '这块报语法错误--EXPECTED EXPRESSION!51Testing软件测试网*XL(_(rFNB
'调用函数
M^[kN|9@|&E0Call CreateFile(strPath,strText)
'p7Y+d&o-dw,~&u7Lf \0Sub CreateFile(strPath,strText)
{M"na*}"kl;F0 Dim objFso,objStream
Wtf+EC)k"qWB0 '创建FileSystemObject对象51Testing软件测试网
r/W9H$^?h
Set bjFso = CreateObject("Scripting.FileSystemObject")
QZ#x0]e1M0 '使用FileSystemObject对象的CreateTextFile(),来返回一个TextStream对象句柄
(DOE+\/Yb\9|\0 Set bjStream = objFso.CreateTextFile(strPath,True)51Testing软件测试网;TKksH
'三个Write的意思分别为:在文本中写入字符、写入带换行符的字符、写入3个换行符
8F]*K
b,YP5v0 objStream.Write(strText)
9HgrslD@0 'objStream.WriteLine(strText)51Testing软件测试网-{OI0hME TR
b%mn
'objStream. WriteBlankLines 3
-xU;x
ua(_9Z\VF0U0 '关闭TextStream对象
5C-rl
Wn0 objStream.Close
z2d5x-h4[ov.?R
_z0End Sub
cDY9R;\D0M!`0把这块
Dim strPath,strText
8u#fO3a_N0strPath = "C:\type.txt"
d R P({dA-V+zE0strText = "This is Test !"& vbCrLf & “hello word !”
修改成
Dim strPath,strText,a,b51Testing软件测试网l]8}2K npG1i#v
xvP
strPath = "C:\TYPE.txt"51Testing软件测试网 ?6Bcd,l"W#_f(j
a= "This is Test !"
s
{5S` \A.Mm0 b="hello world!"51Testing软件测试网3Z'g&R}n7g
strText= a&vbcr &b
问题就解决了
收藏
举报
TAG: