主题:Vb 存取及讀取
samlai20042000
[专家分:0] 发布于 2008-09-22 15:12:00
我想問一下可以用甚麼方法在VB裡將一些用家輸入的資料儲存在TXT檔案,,,又怎樣可以把這些檔案讀取出來,,,,謝謝幫忙
回复列表 (共1个回复)
沙发
一江秋水 [专家分:9680] 发布于 2008-09-22 17:45:00
用Open语句读到Text1中:
Dim txtFileName As String, St As string, Z As String
txtFileName="D:\TxtFiles\001.txt" '这是举个例,要让变量txtFileName等于全路径文件名
Open txtFileName For Input As #1
Do Until EOF(1)
Line Input #1, Z
St = St & Z & vbCrLf
Loop
Close #1
Text1.Text = St
用Save语句把Text1中的资料写到磁盘上:
Dim txtFileName As String, St As string
txtFileName="D:\TxtFiles\001.txt"
St = Text1.Text
Open txtFileName For Output As #1
Print #1, St
Close #1
我来回复