vb.net讀寫數(shù)據(jù)文件,vb從文件中讀取數(shù)據(jù)
vb.net中,讀取和寫入文件
寫入:Dim sr As New IO.StreamWriter(Application.StartupPath "/寫入的文本.txt")
成都創(chuàng)新互聯(lián)是一家專業(yè)提供松溪企業(yè)網(wǎng)站建設(shè),專注與成都做網(wǎng)站、網(wǎng)站設(shè)計(jì)、H5開發(fā)、小程序制作等業(yè)務(wù)。10年已為松溪眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)絡(luò)公司優(yōu)惠進(jìn)行中。
sr.WriteLine("寫入的內(nèi)容") sr.Close()讀取:If (File.Exists(Application.StartupPath "/msg.txt")) Then
Dim fm As New IO.FileStream(Application.StartupPath "/讀取的文本.txt", FileMode.Open)
Dim sr As IO.StreamReader = New IO.StreamReader(fm)
Do While sr.Peek() = 0
TextBox1.Text = sr.ReadLine() (讀取文本到文本框)
Loop end if
VB.net窗體設(shè)計(jì)中,如何讀取.txt文件中的數(shù)據(jù)?
1、新建一個(gè)標(biāo)準(zhǔn)的VB EXE工程,只有一個(gè)Form,F(xiàn)orm上有兩個(gè)按鈕:Command1和Command2。
2、雙擊Command1添加如下代碼
Private Sub Command1_Click()
Dim strFile? ? ?As String
Dim intFile? ? ?As Integer
Dim strData? ? ?As String
strFile = "c:\學(xué)生成績(jī).txt"
intFile = FreeFile
Open strFile For Input As intFile
strData = StrConv(InputB(FileLen(strFile), intFile), vbUnicode)
Debug.Print strData
Close intFile
End Sub
3、按F8開始單步調(diào)試代碼,點(diǎn)擊Command1,進(jìn)入單步調(diào)試功能,
4、多次按下F8或直接按下F5運(yùn)行完成,就完成了讀取文本文件內(nèi)容并輸出到立即窗口。
VB.net 讀取文本文件?
1、實(shí)現(xiàn)上傳按鈕方法代碼。
2、判斷圖片對(duì)象是否為空代碼。
3、取得數(shù)據(jù)庫字段 dt.Rows(0)("Pic")方法代碼。
4、字節(jié)數(shù)組轉(zhuǎn)換為Image類型方法代碼。
5、處理SQL中操作Image類型方法代碼。
6、實(shí)現(xiàn)的上傳結(jié)果。
文章名稱:vb.net讀寫數(shù)據(jù)文件,vb從文件中讀取數(shù)據(jù)
網(wǎng)頁地址:http://www.xueling.net.cn/article/hdphic.html