Re: [.NET] 如何將文字內容存為一個txt檔呢?

看板Visual_Basic作者 (Liu-Liu)時間16年前 (2009/09/02 11:03), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
這是用 Visual Studio 2008 寫出來的 Imports System Imports System.IO Public Class Form1 Dim myfilename As String = "D:\文字檔.txt" Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim sw As New StreamWriter(myfilename) sw.Write(TextBox1.Text) '將 TextBox 文字資料寫入檔案中 sw.Close() '關閉檔案 End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If File.Exists(myfilename) = True Then '判斷檔案是否存在,如果檔案存在,則讀取該檔案 Dim sw As New StreamReader(myfilename) TextBox1.Text = sw.ReadToEnd '將檔案的文字資料讀入 TextBox 內 sw.Close() '關閉檔案 End If End Sub End Class ※ 引述《JYLai (是男人也可以是個男孩~)》之銘言: : 小弟我是個新手~~ : 我想寫個小程式~就是把textbox.text的內容存在d槽為一個文字檔.txt : 我不知指令是什麼 還有要如何宣告~ : 是否有人能寫出程式碼給我參考呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.124.3.111
文章代碼(AID): #1AdU1uit (Visual_Basic)
文章代碼(AID): #1AdU1uit (Visual_Basic)