Dim sFind As String
Dim FileType, FiType As String
Private Sub Delete_Click()
RichTextBox1.Text = “” '清空文本框
End Sub
Private Sub Form_Load()
Me.Height = 6000
Me.Width = 9000
End Sub
Private Sub Form_Resize()
On Error Resume Next '出错处理
RichTextBox1.Top = 20
RichTextBox1.Left = 20
RichTextBox1.Height = ScaleHeight - 40
RichTextBox1.Width = ScaleWidth - 40
End Sub
Private Sub New_Click()
RichTextBox1.Text = “” '清空文本框
FileName = “未命名”
Me.Caption = FileName
End Sub
Private Sub Open_Click()
CommonDialog1.Filter = “文本文档(.txt)│.txt│RTF文档(.rtf)│.rtf│所有文件(.)│*."
CommonDialog1.ShowOpen
RichTextBox1.Text = “” '清空文本框
FileName = CommonDialog1.FileName
RichTextBox1.LoadFile FileName
Me.Caption = “超级记事本:” & FileName
End Sub
Private Sub Save_Click()
CommonDialog1.Filter = "文本文档(.txt)│*.txt│RTF文档(.rtf)│.rtf│所有文件(.)│*."
CommonDialog1.ShowSave
FileType = CommonDialog1.FileTitle
FiType = LCase(Right(FileType, 3))
FileName = CommonDialog1.FileName
Select Case FiType
Case “txt”
RichTextBox1.SaveFile FileName, rtfText
Case “rtf”
RichTextBox1.SaveFile FileName, rtfRTF
Case ".*”
RichTextBox1.SaveFile FileName
End Select
Me.Caption = “超级记事本:” & FileName
End Sub
Private Sub Exit_Click()
End
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
Private Sub Paste_Click()
RichTextBox1.SelText = Clipboard.GetText
End Sub
Private Sub Find_Click()
sFind = InputBox(“请输入要查找的字、词:”, “查找内容”, sFind)
RichTextBox1.Find sFind
End Sub
Private Sub FindOn_Click()
RichTextBox1.SelStart = RichTextBox1.SelStart + RichTextBox1.SelLength + 1
RichTextBox1.Find sFind, , Len(RichTextBox1)
End Sub
Private Sub Readme_Click()
On Error GoTo handler
RichTextBox1.LoadFile “Readme.txt”, rtfText '请写好Readme.txt文件并存入程序所在文件夹中
Me.Caption = “我的记事本:” & “使用说明”
Exit Sub
handler:
MsgBox “使用说明文档可能已经被移除,请与作者联系。”, vbOKOnly, " 提示信息!"
End Sub
Private Sub About_Click()
MsgBox “我的记事本 Ver1.0 版权所有© 2022 圣人”, vbOKOnly, “关于”
End Sub
Private Sub RichTextBox1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
PopupMenu Edit, vbPopupMenuLeftAlign
Else
Exit Sub
End If
End Sub
Private Sub RichTextBox1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeySpace Then
RichTextBox1.SelFontName = CommonDialog1.FontName
End If
End Sub
Private Sub SelecAll_Click()
With RichTextBox1
.SelStart = 0
.SelLength = Len(RichTextBox1.Text)
'让文本框获取焦点
.SetFocus
End With
End Sub