vb open 问题!在线等待!!

2025-04-13 09:08:15
推荐回答(2个)
回答1:

把程序外面的文本信息("C:\p.txt")读取到程序中,使用Input.
把程序里信息(Text1.Text)写到程序外面的文档中,使用Output.

“问题补充:写进去我是用
Dim a As String
Open "c:\p.txt" For Output As #1
Input #1, a
Close #1
但是不行???”
-----------这是你的问题补充。

你既然用For OutPut,意思是向文档写东西,但又为什么下面用Input #1, a呢?
应该改成Output #1 ,a 或者Print #1,a

回答2:

Dim a As String
Open "c:\p.txt" For Output As #1
Input #1, a-????????????????????
Close #1

已经说了是Output,为什么还要使用Input
既然是读取文本文件,解决很简单

输出时为
Open Pathname for output as #1'空闲的文件号
print #1,String'String为你要写入的文字
close #1'必要,否则下次会出错

读取时就像你刚才写的一样,不过更一般的,我们使用Line Input逐行读入
open pathname for input as #1
line input #1,String
close #1