If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then

站在用戶的角度思考問(wèn)題,與客戶深入溝通,找到霍山網(wǎng)站設(shè)計(jì)與霍山網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都網(wǎng)站建設(shè)、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名注冊(cè)、網(wǎng)頁(yè)空間、企業(yè)郵箱。業(yè)務(wù)覆蓋霍山地區(qū)。
My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, "1111", True)
End If
就可以了
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
寫入:Dim sr As New IO.StreamWriter(Application.StartupPath "/寫入的文本.txt")
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
按你說(shuō)的方式,需要用到鉤子
建議你用File類進(jìn)行操作,保存為TXT文件
祝好運(yùn),望采納
如果想繼續(xù)編輯之前的文檔,在TXT文件尾部繼續(xù)添加文本,那么還需要在函數(shù)后邊加個(gè)參數(shù)。
VB 代碼
方法1:
? Dim?sw?As?StreamWriter =?New?StreamWriter("C:\temp\test.txt")
? sw.Write("abc"? vbCrLf)
sw.Close()
Dim?sw2?As?StreamWriter =?New?StreamWriter("C:\temp\test.txt",?True)
sw2.Write("456"? vbCrLf)
sw2.Close()
方法2:
? My.Computer.FileSystem.WriteAllText("test.txt",?"This is test Text",?True)
方法3:
? System.IO.File.AppendAllText("c:\temp\test.txt",?"this is extra test file")
詳見(jiàn):“網(wǎng)頁(yè)鏈接”?
窗體上添加2個(gè)文本框,設(shè)置成多行,2個(gè)按鈕,在文本框1里隨便輸入若干文字,可以多行,單擊按鈕1,保存到文件。然后單擊按鈕2,把剛才寫入的文件讀到文本框2里。
代碼如下:
'寫文本文件
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'創(chuàng)建(寫入)一個(gè)文本文件
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
'讀取一個(gè)文本文件
Dim MyReader As New System.IO.StreamReader(Application.StartupPath "\Ssk.txt", System.Text.Encoding.UTF8)
TextBox2.Text = MyReader.ReadToEnd()
MyReader.Close()
End Sub
氣斜射入水或其他介質(zhì),折射光線與入射光線法線在
文章標(biāo)題:vb.net中寫文本文件,vbs 寫文件
文章鏈接:http://chinadenli.net/article45/dsijdei.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化、網(wǎng)站策劃、品牌網(wǎng)站建設(shè)、App開(kāi)發(fā)、建站公司、ChatGPT
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)