用VB程序编写设计一个简易记事本,要求能够实现“复制”、“剪切”、“粘贴”、“退出”功能
1个回答
展开全部
Dim sFind As String
Dim FileType, FilterType As String
Private Sub Form_Load()
Me.Height = 6000
Me.Width = 9000
End Sub
Private Sub Form_Resize()
On Error Resume Next
RichTextBox1.Top = 5
RichTextBox1.Left = 5
RichTextBox1.Height = ScaleHeight - 40
RichTextBox1.Width = ScaleWidth - 40
End Sub
Private Sub mnuALL_Click()
RichTextBox1.SelStart = 0
RichTextBox1.SelLength = Len(RichTextBox1.Text)
End Sub
Private Sub mnuCopy_Click()
Clipboard.Clear
Clipboard.SetText RichTextBox1.SelText
End Sub
Private Sub mnuCut_Click()
Clipboard.Clear
Clipboard.SetText RichTextBox1.SelText
RichTextBox1.SelText = ""
End Sub
Private Sub mnuExit_Click()
End
End Sub
Private Sub mnuFind_Click()
sFind = InputBox("请输入要查找的字符", "查找")
RichTextBox1.Find sFind
End Sub
Private Sub mnuFindNext_Click()
RichTextBox1.SelStart = RichTextBox1.SelStart + RichTextBox1.SelLength + 1
RichTextBox1.Find sFind, , RichTextBox1
End Sub
Private Sub mnuNew_Click()
RichTextBox1.Text = ""
FileName = "未命名"
Me.Caption = FileName
End Sub
Private Sub mnuOpen_Click()
CommonDialog1.Filter = "文本文档(*.txt)|*.txt|rtf文档(*.rtf)|*.rtf|所有文件(*.*)|*.*"
CommonDialog1.ShowOpen
FileName = CommonDialog1.FileName
RichTextBox1.Text = ""
RichTextBox1.LoadFile FileName
Me.Caption = "超级记事本:" & FileName
End Sub
Private Sub mnuPaste_Click()
RichTextBox1.SelText = Clipboard.GetText
End Sub
Private Sub mnuSvae_Click()
CommonDialog1.Filter = "文本文档(*.txt)|*.txt|rtf文档(*.rtf)|*.rtf|所有文件(*.*)|*.*"
CommonDialog1.ShowSave
FileType = CommonDialog1.FileTitle
FilterType = LCase(Right(FileType, 3))
FileName = CommonDialog1.FileName
Select Case FilterType
Case "txt"
RichTextBox1.SaveFile FileName, rtfText
Case "rtf"
RichTextBox1.SaveFile FileName, rtfRTF
Case "*.*"
RichTextBox1.SaveFile FileName
End Select
Me.Caption = "超级记事本:" & FileName
End Sub
这是全部代码,如果楼主有需要。我可以将整个工程文件发到你邮箱
Dim FileType, FilterType As String
Private Sub Form_Load()
Me.Height = 6000
Me.Width = 9000
End Sub
Private Sub Form_Resize()
On Error Resume Next
RichTextBox1.Top = 5
RichTextBox1.Left = 5
RichTextBox1.Height = ScaleHeight - 40
RichTextBox1.Width = ScaleWidth - 40
End Sub
Private Sub mnuALL_Click()
RichTextBox1.SelStart = 0
RichTextBox1.SelLength = Len(RichTextBox1.Text)
End Sub
Private Sub mnuCopy_Click()
Clipboard.Clear
Clipboard.SetText RichTextBox1.SelText
End Sub
Private Sub mnuCut_Click()
Clipboard.Clear
Clipboard.SetText RichTextBox1.SelText
RichTextBox1.SelText = ""
End Sub
Private Sub mnuExit_Click()
End
End Sub
Private Sub mnuFind_Click()
sFind = InputBox("请输入要查找的字符", "查找")
RichTextBox1.Find sFind
End Sub
Private Sub mnuFindNext_Click()
RichTextBox1.SelStart = RichTextBox1.SelStart + RichTextBox1.SelLength + 1
RichTextBox1.Find sFind, , RichTextBox1
End Sub
Private Sub mnuNew_Click()
RichTextBox1.Text = ""
FileName = "未命名"
Me.Caption = FileName
End Sub
Private Sub mnuOpen_Click()
CommonDialog1.Filter = "文本文档(*.txt)|*.txt|rtf文档(*.rtf)|*.rtf|所有文件(*.*)|*.*"
CommonDialog1.ShowOpen
FileName = CommonDialog1.FileName
RichTextBox1.Text = ""
RichTextBox1.LoadFile FileName
Me.Caption = "超级记事本:" & FileName
End Sub
Private Sub mnuPaste_Click()
RichTextBox1.SelText = Clipboard.GetText
End Sub
Private Sub mnuSvae_Click()
CommonDialog1.Filter = "文本文档(*.txt)|*.txt|rtf文档(*.rtf)|*.rtf|所有文件(*.*)|*.*"
CommonDialog1.ShowSave
FileType = CommonDialog1.FileTitle
FilterType = LCase(Right(FileType, 3))
FileName = CommonDialog1.FileName
Select Case FilterType
Case "txt"
RichTextBox1.SaveFile FileName, rtfText
Case "rtf"
RichTextBox1.SaveFile FileName, rtfRTF
Case "*.*"
RichTextBox1.SaveFile FileName
End Select
Me.Caption = "超级记事本:" & FileName
End Sub
这是全部代码,如果楼主有需要。我可以将整个工程文件发到你邮箱
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询