1个richtextbox,1个commondialog,菜单蓝设计好 打开文件代码: Private Sub Open_Click() If ChangeTxt Then If MsgBox("是否将更改保存到 " & FilePath & "?", vbYesNo + vbQuestion, "记事本") = vbYes Then Save_Click End If End If CommonDialog1.Filter = "文本文档(*.txt)|*.txt|所有文件(*.*)|*.*" CommonDialog1.FilterIndex = 1 CommonDialog1.ShowOpen FilePath = CommonDialog1.FileName FileName = Right(FilePath, Len(FilePath) - InStrRev(FilePath, "\")) OpenFile FilePath End Sub Private Sub OpenFile(FilePath As String) Dim F As Integer Dim FileStr As String On Error GoTo errhandler F = FreeFile FileStr = "" Open FilePath For Input As F Do While Not EOF(F) FileStr = FileStr + Input(1, #1) Loop Close F Form1.RichTextBox1.Text = FileStr Form1.Caption = FileName & " - 记事本" Exit Sub errhandler: MsgBox "打开文件出错,请重试", 48, "系统提示" Close F Exit Sub End Sub 保存那些类同 剪切复制代码如下: Private Sub Copy_Click() Clipboard.Clear Clipboard.SetText RichTextBox1.SelText End Sub Private Sub Cut_Click() Clipboard.Clear Clipboard.SetText RichTextBox1.SelText RichTextBox1.SelText = "" End Sub 主要功能就这样设计,个别功能需要自己完善,如果有兴趣还可以做出比windows自带的更强大的记事本,如添加字数统计等功能。
温馨提示:答案为网友推荐,仅供参考