超级小白问题:VB如何输出到一个文本?

2025-05-06 03:44:47
推荐回答(2个)
回答1:

问题1:
open app.path & "\abc.txt" for output as #1
print #1,"abc"
close #1

问题2:
dim a as double
a=0
open app.path & "\abc.txt" for output as #1
print #1,a
close #1

问题3:
dim a as double
a=0
open app.path & "\abc.txt" for output as #1
print #1,"abc"
print #1,a
close #1

回答2:

如果你会fso的话,那很简单。
利用fso.opentextfile()写文件
set fso=new fielsystemobject
set fi=fso.opentextfile("abc.txt",forwriting,true)
写字符串就用fi.write("abc")
写变量就用fi.write(A)
两个一起写就是fi.write("abc" & vbcrlf & A)
vbcrlf是换行用的
否则,直接用文件读写