简单文件读出问题!

zhourongbiao 2003-11-18 08:16:18
写入语句:
Open "c:\src.txt" For Output As #1
Print #1, " 学生成绩表"
Print #1,
Print #1, "姓名"; Tab; "成绩"; Tab; "备注" ' 数据写入三个区
Print #1, "王维"; " "; "95"
Print #1, "黄梅"; " "; "0";
Print #1, Spc(15); "舞弊"
Print #1, Tab(5); " 输入完毕!"
Close #1

读出语句:
Text1.Text = ""
Open "c:\src.txt" For Input As #1
'MsgBox LOF(1)
Text1.Text = Input(LOF(1), #1) '出错!说超过文件尾,why?怎么改?
Close #1

我就要一次读出,请勿回答用 Line Input#和逐个读出(用EOF和Input(1,#1)),谢谢!
...全文
30 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
pigsanddogs 2003-11-23
  • 打赏
  • 举报
回复
我这里可以
pigsanddogs 2003-11-23
  • 打赏
  • 举报
回复
我这里而已
FSoft 2003-11-21
  • 打赏
  • 举报
回复
dim a as string,b as string
Open "c:\src.txt" For Input As #1
do while not eof(#1)
line input #1,a
b=b & vbcrlf & a
loop
Close #1
text1.text=b
yoki 2003-11-21
  • 打赏
  • 举报
回复
Open "c:\src.txt" For Input As #1
text1.text = StrConv(InputB(LOF(1), #1), vbUnicode)
Close #1
yoki 2003-11-21
  • 打赏
  • 举报
回复
Dim strTmp As String
Dim strArray() As String
Open "c:\src.txt" For Input As #1
text1.text = StrConv(InputB(LOF(1), #1), vbUnicode)
Close #1
rainstormmaster 2003-11-21
  • 打赏
  • 举报
回复
dim buff() as byte
dim i as long
i=filelen("c:\src.txt")
redim buff(i-1)
open "c:\src.txt" for binary as #1
get #1,,buff
close #1
dim s as string
s=strconv(buff,vbunicode)
Text1.Text = s
gongfucai 2003-11-21
  • 打赏
  • 举报
回复
dim b as string
Input #1,b
Text1.Text=b
zhourongbiao 2003-11-18
  • 打赏
  • 举报
回复
to:pigsanddogs(我爱吃猪肉,但是长不胖,为什么??)
不行的!
pigsanddogs 2003-11-18
  • 打赏
  • 举报
回复
input(lof(1)-1, #1)试试?

7,732

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧