vb io读写

简写代码

写入:

Imports System.IO.File

Dim disco As System.IO.File
Dim scrivi As System.IO.StreamWriter
scrivi=disco.AppendText("c:\data.txt")
scrivi.WriteLine(TextBox1.Text)
scrivi.WriteLine(TextBox2.Text)
scrivi.WriteLine(TextBox3.Text)
scrivi.WriteLine(TextBox4.Text)
scrivi.Close()


读出:

Imports System.IO.File

Dim disco As System.IO.File
Dim leggi As System.IO.StreamReader
Dim riga As String
leggi=disco.OpenText("c:\data.txt")
if textbox1.text ="" then msgbox("not data")
While leggi.Peek <> -1
riga=leggi.ReadLine()
if riga=Textbox1.text then exit while
end while
textbox2.text=leggi.Readline()
textbox3.text=leggi.Readline()
textbox4.text=leggi.Readline()




写入的文本数据:
01/01/2013       ‘数据头

hello

2

email.com

01/02/2013      ‘数据头

zxl

1

163.com


读取文件时 根据数据头判断取出的数据


你可能感兴趣的:(vb io读写)