我写的记事本,大家多提意见
大部分内容可以说是比着书做的,不过还是一句句的明白了,这个记事本,还可以再增强一些什么功能呢?我想再修改完善一下?
Private Sub Form_Load()
Me.Left = GetSetting(App.Title, "Settings ", "MainLeft ", 1000)
Me.Top = GetSetting(App.Title, "Settings ", "MainTop ", 1000)
Me.Width = GetSetting(App.Title, "Settings ", "MainWidth ", 6500)
Me.Height = GetSetting(App.Title, "Settings ", "MainHeight ", 6500)
Me.Caption = "大头怪笔记本 "
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim i As Integer
'close all sub forms
For i = Forms.Count - 1 To 1 Step -1
Unload Forms(i)
Next
If Me.WindowState <> vbMinimized Then
SaveSetting App.Title, "Settings ", "MainLeft ", Me.Left
SaveSetting App.Title, "Settings ", "MainTop ", Me.Top
SaveSetting App.Title, "Settings ", "MainWidth ", Me.Width
SaveSetting App.Title, "Settings ", "MainHeight ", Me.Height
End If
End Sub
Private Sub mnumnutextmnutextc_Click()
mnumnutextmnutextr.Checked = False
mnumnutextmnutextl.Checked = False
mnumnutextmnutextc.Checked = True
RichTextBox1.SelAlignment = 2
End Sub
Private Sub RichTextBox1_Change()
End Sub
Private Sub tbToolBar_ButtonClick(ByVal Button As MSComCtlLib.Button)
On Error Resume Next
Select Case Button.Key
Case "新建 "
'应做:添加 '新建 ' 按钮代码。
mnuFileNew_Click
Case "打开 "
mnuFileOpen_Click
Case "保存 "
mnuFileSave_Click
Case "打印 "
mnuFilePrint_Click
Case "剪切 "
mnuEditCut_Click
Case "复制 "
mnuEditCopy_Click
Case "粘贴 "
mnuEditPaste_Click
Case "粗体 "
mnumnutextmnutextbold_Click
Case "斜体 "
Case "下划线 "
mnumnutextmnutextunderline_Click
Case "左对齐 "
mnumnutextmnutextl_Click
Case "置中 "
mnumnutextmnutextc_Click
Case "右对齐 "
End Select
End Sub
Private Sub mnuHelpAbout_Click()
frmAbout.Show vbModal, Me
End Sub
Private Sub mnuViewStatusBar_Click()
mnuViewStatusBar.Checked = Not mnuViewStatusBar.Checked
sbStatusBar.Visible = mnuViewStatusBar.Checked
End Sub
Private Sub mnuViewToolbar_Click()
mnuViewToolbar.Checked = Not mnuViewToolbar.Checked
tbToolBar.Visible = mnuViewToolbar.Checked
End Sub
Private Sub mnumnutexttextr_Click()
mnumnutextmnutextr.Checked = True
mnumnutextmnutextc.Checked = False
mnumnutextmnutextl.Checked = False
RichTextBox1.SelAlignment = 1
End Sub
Private Sub mnumnutextmnutextl_Click()
mnumnutextmnutextr.Checked = Fals
mnumnutextmnutextc.Checked = False
mnumnutextmnutextl.Checked = True
RichTextBox1.SelAlignment = 0
End Sub
Private Sub mnumnutextmnutextunderline_Click()
RichTextBox1.SelItalic = Not RichTextBox1.SelItalic
End Sub
Private Sub mnumnutextmnutextbold_Click()
RichTextBox1.SelBold = Not RichTextBox1.SelBold
End Sub
Private Sub mnumnutextmnutextcolor_Click()
dlgCommonDialog.ShowColor
RichTextBox1.SelColor = dlgCommonDialog.Color
End Sub
Private Sub mnumnutextmnutextfont_Click()
dlgCommonDialog.Flags = cdlCFBoth
dlgCommonDialog.ShowFont
RichTextBox1.SelFontName = dlgCommonDialog.FontName
RichTextBox1.SelFontSize = dlgCommonDialog.FontSize
RichTextBox1.SelBold = dlgCommonDialog.FontBold '粗体
RichTextBox1.SelItalic = dlgCommonDialog.FontItalic '斜体
End Sub
Private Sub mnuEditPaste_Click()
RichTextBox1.SelText = Clipboard.GetText()
End Sub
Private Sub mnuEditCopy_Click()
Clipboard.SetText RichTextBox1.SelText
End Sub
Private Sub mnuEditCut_Click()
Clipboard.SetText RichTextBox1.SelText
RichTextBox1.Text = " "
End Sub
Private Sub mnuFileExit_Click()
'卸载窗体
Unload Me
End Sub
Private Sub mnuFilePrint_Click()
'应做:添加 'mnuFilePrint_Click ' 代码。
MsgBox "添加 'mnuFilePrint_Click ' 代码。 "
End Sub
Private Sub mnuFileSaveAs_Click()
'应做:添加 'mnuFileSaveAs_Click ' 代码。
Dim sfile As String
With dlgCommonDialog
.DialogTitle = "另村委 "
.Filter = "所有文件(*.*)|*.* "
.ShowSave
If Len(.FileName) = 0 Then
Exit Sub
Else
sfile = .FileName
End If
End With
RichTextBox1.SaveFile sfile
Caption = sfile
End Sub
Private Sub mnuFileSave_Click()
sfile = Caption
If sfile = "记事本 " Then
mnuFileSaveAs_Click
Else
RichTextBox1.SaveFile sfile
End If
End Sub
Private Sub mnuFileOpen_Click()
Dim sfile As String
With dlgCommonDialog
.DialogTitle = "打开 "
.Filter = "所有文件 (*.*)|*.* "
.ShowOpen
If Len(.FileName) = 0 Then
Exit Sub
End If
sfile = .FileName
End With
RichTextBox1.LoadFile sfile
'ToDo: 添加处理打开的文件的代码
End Sub
Private Sub mnuFileNew_Click()
frmMain.Caption = "大头怪笔记本 "
RichTextBox1.Text = " "
End Sub
[解决办法]