VB.Net 2008 记事本代码

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

Public Class Form1
     Dim a As Integer

     Sub open()
         OpenFileDialog1.FileName = ""
         OpenFileDialog1.ShowDialog()
         If OpenFileDialog1.FileName <> "" Then
             RichTextBox1.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText)
         End If
     End Sub

     Sub save()
         SaveFileDialog1.ShowDialog()
         If SaveFileDialog1.FileName <> "" Then
             RichTextBox1.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText)
         End If
     End Sub

     Private Sub 新建ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 新建ToolStripMenuItem.Click
         If RichTextBox1.TextLength > 0 Then
             a = MsgBox("是否保存文档?", 3, "提示")
             If a = 6 Then
                 save()
                 RichTextBox1.Clear()
             End If
             If a = 7 Then RichTextBox1.Clear()
         End If
         If RichTextBox1.TextLength = 0 Then RichTextBox1.Clear()
     End Sub

     Private Sub 打开ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 打开ToolStripMenuItem.Click
         If RichTextBox1.TextLength > 0 Then
             a = MsgBox("是否保存文档?", 3, "提示")
             If a = 6 Then
                 save()
                 open()
             End If
             If a = 7 Then open()
         End If
         If RichTextBox1.TextLength = 0 Then open()
     End Sub

     Private Sub 保存ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 保存ToolStripMenuItem.Click
         If RichTextBox1.TextLength > 0 Then
             save()
         End If
     End Sub

     Private Sub 退出ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 退出ToolStripMenuItem.Click
         If RichTextBox1.TextLength > 0 Then
             a = MsgBox("是否保存文档?", 3, "提示")
             If a = 6 Then
                 save()
                 Close()
             End If
             If a = 7 Then Close()
         End If
         If RichTextBox1.TextLength = 0 Then Close()
     End Sub

     Private Sub 撤消ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 撤消ToolStripMenuItem.Click
         RichTextBox1.Undo()
     End Sub

     Private Sub 剪贴ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 剪贴ToolStripMenuItem.Click
         RichTextBox1.Cut()
     End Sub

     Private Sub 复制ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 复制ToolStripMenuItem.Click
         RichTextBox1.Copy()
     End Sub

     Private Sub 粘贴ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 粘贴ToolStripMenuItem.Click
         RichTextBox1.Paste()
     End Sub

     Private Sub 删除ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 删除ToolStripMenuItem.Click
         RichTextBox1.Cut()
     End Sub

     Private Sub 查找ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 查找ToolStripMenuItem.Click
         Dim a As String
         a = InputBox("请输入要查找的字、词:", "查找内容", )
         RichTextBox1.Find(a)
     End Sub

     Private Sub 全选ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 全选ToolStripMenuItem.Click
         RichTextBox1.SelectAll()
     End Sub

     Private Sub 自动换行ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 自动换行ToolStripMenuItem.Click
         自动换行ToolStripMenuItem.Checked = Not 自动换行ToolStripMenuItem.Checked
         RichTextBox1.WordWrap = Not RichTextBox1.WordWrap
     End Sub

     Private Sub 字体ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 字体ToolStripMenuItem.Click
         FontDialog1.ShowDialog()
         RichTextBox1.SelectionFont = FontDialog1.Font
     End Sub

     Private Sub 帮助主题ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 帮助主题ToolStripMenuItem.Click
         MsgBox("没有做帮主文档,如确实需要,请与作者联系。", vbOKOnly, " 错误信息")
     End Sub

     Private Sub 关于ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 关于ToolStripMenuItem.Click
         MsgBox("该记事本由Sxgkwei创作", vbOKOnly, " 关于")
     End Sub

     Private Sub 剪贴ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 剪贴ToolStripMenuItem1.Click
         RichTextBox1.Cut()
     End Sub

     Private Sub 复制ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 复制ToolStripMenuItem1.Click
         RichTextBox1.Copy()
     End Sub

     Private Sub 粘贴ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 粘贴ToolStripMenuItem1.Click
         RichTextBox1.Paste()
     End Sub

     Private Sub 删除ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 删除ToolStripMenuItem1.Click
         RichTextBox1.Cut()
     End Sub

     Private Sub 全选ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 全选ToolStripMenuItem1.Click
         RichTextBox1.SelectAll()
     End Sub
End Class