今天做了 文字編輯程式 (類似記事本)

需要 2個 Dialog物件 分別為 openfiledialog1及 savefiledialog1
一個textbox

程式碼如下

Public Class Form1

Private Sub MenuStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles MenuStrip1.ItemClicked

End Sub

Private Sub 檔案FToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 檔案FToolStripMenuItem.Click

End Sub

Private Sub 儲存檔案SToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 儲存檔案SToolStripMenuItem.Click
If SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, _
TextBox1.Text, False)
End If
End Sub

Private Sub 開啟檔案OCtrloToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 開啟檔案OCtrloToolStripMenuItem.Click
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
TextBox1.Text = My.Computer.FileSystem.ReadAllText _
(OpenFileDialog1.FileName)
End If
End Sub
End Class

有一些 可自行修改

完成後 如下圖


創作者介紹

↖Ι n V a D e R ╮

ip612256374 發表在 痞客邦 PIXNET 留言(1) 人氣()


留言列表 (1)

發表留言
  • freedom3142  路人
  • 感謝你!!
    我知道怎麼用了^^