Visual Studio 2010旗舰版的 VB.NET记事本程序代码

Public Class Form1

Private Sub NewToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles NewToolStripMenuItem.Click
    RichTextBox1.Clear()
End Sub

Private Sub OpenToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles OpenToolStripMenuItem.Click
    Dim openFileDialog1 As New OpenFileDialog()
    openFileDialog1.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
    openFileDialog1.FilterIndex = 1
    openFileDialog1.RestoreDirectory = True

    If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
        Try
            Dim sr As New System.IO.StreamReader(openFileDialog1.FileName)
            RichTextBox1.Text = sr.ReadToEnd()
            sr.Close()
        Catch ex As Exception
            MessageBox.Show("Error: Could not read file from disk. Original error: " & ex.Message)
        End Try
    End If
End Sub

Private Sub SaveToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles SaveToolStripMenuItem.Click
    If Not String.IsNullOrEmpty(RichTextBox1.Text) Then
        If Not String.IsNullOrEmpty(SaveFileDialog1.FileName) Then
            My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, RichTextBox1.Text, False)
        Else
            SaveAsToolStripMenuItem.PerformClick()
        End If
    End If
End Sub

Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles SaveAsToolStripMenuItem.Click
    Dim saveFileDialog1 As New SaveFileDialog()

    saveFileDialog1.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
    saveFileDialog1.FilterIndex = 1
    saveFileDialog1.RestoreDirectory = True

    If saveFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
        My.Computer.FileSystem.WriteAllText(saveFileDialog1.FileName, RichTextBox1.Text, False)
        saveFileDialog1.FileName = saveFileDialog1.FileName
    End If
End Sub

Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ExitToolStripMenuItem.Click
    Me.Close()
End Sub

Private Sub UndoToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles UndoToolStripMenuItem.Click
    RichTextBox1.Undo()
End Sub

Private Sub CutToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CutToolStripMenuItem.Click
    RichTextBox1.Cut()
End Sub

Private Sub CopyToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CopyToolStripMenuItem.Click
    RichTextBox1.Copy()
End Sub

Private Sub PasteToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles PasteToolStripMenuItem.Click
    RichTextBox1.Paste()
End Sub

Private Sub DeleteToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles DeleteToolStripMenuItem.Click
    RichTextBox1.SelectedText = ""
End Sub

Private Sub FontToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles FontToolStripMenuItem.Click
    Dim fontDialog1 As New FontDialog()

    If fontDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
        RichTextBox1.Font = fontDialog1.Font
    End If
End Sub

Private Sub AboutNotepadToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles AboutNotepadToolStripMenuItem.Click
    MessageBox.Show("Notepad" & vbCrLf & "Version 1.0" & vbCrLf & "©2022 Microsoft Corporation. All rights reserved.")
End Sub

Private Sub SelectAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAllToolStripMenuItem.Click
    RichTextBox1.SelectAll()
End Sub

End Class

提示:本软件由VS2010旗舰版的VB.NET版本编写,对于其他VS2019或者VS2020都可能无法正常使用。请先确认VS2010旗舰版的VB.NET能正常使用。
有需要可以在下面这个地址下载源代码文件。

https://download.csdn.net/download/qq_32257509/89435571

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

EasySoft易软

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值