按你說的方式,需要用到鉤子
創新互聯專注于黟縣網站建設服務及定制,我們擁有豐富的企業做網站經驗。 熱誠為您提供黟縣營銷型網站建設,黟縣網站制作、黟縣網頁設計、黟縣網站官網定制、成都微信小程序服務,打造黟縣網絡公司原創品牌,更為您提供黟縣網站排名全網營銷落地服務。
建議你用File類進行操作,保存為TXT文件
祝好運,望采納
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim aa As System.IO.StreamWriter = New System.IO.StreamWriter("C:\a.txt", False, System.Text.Encoding.UTF8)
Dim i As Integer = 0
For i = 0 To Val(TextBox4.Text)
aa.WriteLine("[" i "]")
aa.WriteLine("[" i "]")
Next
aa.Close()
aa.Dispose()
End Sub
設計一個窗口,添加一個名為textBox1的System.Windows.Forms.TextBox,
添加一個名為button1的System.Windows.Forms.Button。
為button1的單擊事件添加如下處理函數:
Sub Button1Click(sender As Object, e As EventArgs)
'f是你的文本文件的文件名
Const f As String="t.txt"
Dim sw As System.IO.StreamWriter=Nothing
Try
If Not System.IO.File.Exists(f) Then
sw=System.IO.File.CreateText(f)
Else
sw=New System.IO.StreamWriter(f,True)
End If
sw.WriteLine(textBox1.Text)
Finally
If sw IsNot Nothing Then
sw.close()
End If
End Try
End Sub
寫入:Dim sr As New IO.StreamWriter(Application.StartupPath "/寫入的文本.txt")
sr.WriteLine("寫入的內容") sr.Close()讀?。篒f (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
窗體上添加2個文本框,設置成多行,2個按鈕,在文本框1里隨便輸入若干文字,可以多行,單擊按鈕1,保存到文件。然后單擊按鈕2,把剛才寫入的文件讀到文本框2里。
代碼如下:
'寫文本文件
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'創建(寫入)一個文本文件
Dim MyStream As New System.IO.FileStream(Application.StartupPath "\Ssk.txt", System.IO.FileMode.Create)
Dim MyWriter As New System.IO.StreamWriter(MyStream, System.Text.Encoding.Default)
MyWriter.WriteLine(TextBox1.Text)
MyWriter.Flush()
MyWriter.Close()
MyStream.Close()
End Sub
'讀文本文件
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'讀取一個文本文件
Dim MyReader As New System.IO.StreamReader(Application.StartupPath "\Ssk.txt", System.Text.Encoding.UTF8)
TextBox2.Text = MyReader.ReadToEnd()
MyReader.Close()
End Sub
氣斜射入水或其他介質,折射光線與入射光線法線在
網頁名稱:vb.net寫文本文件,vb讀寫文本文件
文章出自:http://m.kartarina.com/article12/hddodc.html
成都網站建設公司_創新互聯,為您提供網站排名、ChatGPT、網站設計、電子商務、網頁設計公司、移動網站建設
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯