Private Sub mnuOpen_Click()
CommonDialog1.Filter = "文本文档(*.txt)|*.txt|RTF文档(*.rtf)|*.rtf|所有文件(*.*)|*.*"
CommonDialog1.ShowOpen
RichTextBox1.Text = ""
FileName = CommonDialog1.FileTitle
RichTextBox1.LoadFile CommonDialog1.FileName
Me.Caption = "超级记事本:" & CommonDialog1.FileName
FileType = Right(FileName, Len(FileName) - InStr(FileName, ".")) '不可加一,加一后文件名变为*..*
End Sub
Private Sub mnuSave_Click()
If InStr(CommonDialog1.FileName, ".") <> 0 Then
CommonDialog1.FileName=Left(CommonDialog1.FileName,InStr(CommonDialog1.FileName, ".") - 1)
End If
CommonDialog1.DefaultExt = FileType
CommonDialog1.Filter = "文本文档(*.txt)|*.txt|RTF文档(*.rtf)|*.rtf|所有文件(*.*)|*.*"
CommonDialog1.ShowSave
FileName = CommonDialog1.FileName
Select Case CommonDialog1.FilterIndex
Case 1
RichTextBox1.SaveFile FileName, rtfText
Case 2
RichTextBox1.SaveFile FileName, rtfRTF
Case 3
RichTextBox1.SaveFile FileName
End Select
Me.Caption = "超级记事本:" & FileName
End Sub
以上程序是针对打开和保存这两个菜单的修改!本人愚见楼主见笑!