主题:如何读写文本文件
zhengzexiao
[专家分:0] 发布于 2009-12-27 10:48:00
添加6个TEXT,2个COMMAND,TEXT1.TEXT="100",TEXT2.TEXT="200",TEXT3.TEXT="300",TEXT4.TEXT="400",TEXT5.TEXT="500",TEXT6.TEXT="600"。如何通过点击COMMAND1,保存为TXT格式(用TAB隔开)如下:
1 100 200 300
2 400 500 600
点击COMMAND2再读回来
最后更新于:2009-12-27 14:09:00
回复列表 (共2个回复)
沙发
一江秋水 [专家分:9680] 发布于 2009-12-27 16:33:00
写:
Dim St as strint
st="1 " & text1 & " " & text2 & " " text3 & vbCrLf & "2 " & text4 & " " & text5 & " " & text6
Open Nam For Output As #1
Print #1, St
Close
读:
Dim St as strint
Open Nam For Input As #1
Do Until EOF(1)
Line Input #1, st
text1=mid(st,instr(st,"100"),3)
text2=mid(st,instr(st,"200"),3)
text3=mid(st,instr(st,"300"),3)
Line Input #1, st
text4=mid(st,instr(st,"400"),3)
text5=mid(st,instr(st,"500"),3)
text6=mid(st,instr(st,"600"),3)
Loop
Close #1
我来回复