按你說的方式,需要用到鉤子
創(chuàng)新互聯(lián)專注于黟縣網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供黟縣營銷型網(wǎng)站建設(shè),黟縣網(wǎng)站制作、黟縣網(wǎng)頁設(shè)計、黟縣網(wǎng)站官網(wǎng)定制、成都微信小程序服務(wù),打造黟縣網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供黟縣網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。
建議你用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
設(shè)計一個窗口,添加一個名為textBox1的System.Windows.Forms.TextBox,
添加一個名為button1的System.Windows.Forms.Button。
為button1的單擊事件添加如下處理函數(shù):
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("寫入的內(nèi)容") 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個文本框,設(shè)置成多行,2個按鈕,在文本框1里隨便輸入若干文字,可以多行,單擊按鈕1,保存到文件。然后單擊按鈕2,把剛才寫入的文件讀到文本框2里。
代碼如下:
'寫文本文件
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'創(chuàng)建(寫入)一個文本文件
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
氣斜射入水或其他介質(zhì),折射光線與入射光線法線在