📄 form1.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
Caption = "记事本"
ClientHeight = 3165
ClientLeft = 165
ClientTop = 735
ClientWidth = 6615
LinkTopic = "Form1"
ScaleHeight = 211
ScaleMode = 3 'Pixel
ScaleWidth = 441
StartUpPosition = 3 '窗口缺省
Begin MSComDlg.CommonDialog CommonDialog1
Left = 3960
Top = 1080
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.TextBox TextEdit
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3180
Left = 0
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 0
Top = 0
Width = 6615
End
Begin VB.Menu mnuFile
Caption = "文件(&F)"
Begin VB.Menu mnuFileNew
Caption = "新建(&N)..."
Shortcut = ^N
End
Begin VB.Menu mnuFileOpen
Caption = "打开(&O)..."
Shortcut = ^O
End
Begin VB.Menu mnuFileClose
Caption = "关闭(&C)"
End
Begin VB.Menu mnubar11
Caption = "-"
End
Begin VB.Menu mnuFileSave
Caption = "保存(&S)"
Shortcut = ^S
End
Begin VB.Menu mnuFileSaveAs
Caption = "另存为(&A)..."
End
Begin VB.Menu mnubar12
Caption = "-"
End
Begin VB.Menu mnuFilePage
Caption = "页面设置(&T)..."
End
Begin VB.Menu mnuFilePrint
Caption = "打印(&P)"
End
Begin VB.Menu DynaBar
Caption = "-"
Visible = 0 'False
End
Begin VB.Menu DynaMnu
Caption = ""
Index = 0
Visible = 0 'False
End
Begin VB.Menu mnubar13
Caption = "-"
End
Begin VB.Menu mnuExit
Caption = "退出(&X)"
End
End
Begin VB.Menu mnuEdit
Caption = "编辑(&E)"
Begin VB.Menu mnuEditUndo
Caption = "撤消(&U)"
Shortcut = ^Z
End
Begin VB.Menu mnuBar21
Caption = "-"
End
Begin VB.Menu mnuEditCut
Caption = "剪切(&T)"
Shortcut = ^X
End
Begin VB.Menu mnuEditCopy
Caption = "复制(&C)"
Shortcut = ^C
End
Begin VB.Menu mnuEditPaste
Caption = "粘贴(&P)"
Shortcut = ^V
End
Begin VB.Menu mnuEditdel
Caption = "删除(&L)"
Shortcut = {DEL}
End
Begin VB.Menu mnuBar22
Caption = "-"
End
Begin VB.Menu mnuEditAll
Caption = "全选(&A)"
Shortcut = ^A
End
Begin VB.Menu mnuEditDate
Caption = "时间/日期(&D)"
Shortcut = {F8}
End
End
Begin VB.Menu mnuSerach
Caption = "搜索(&S)"
End
Begin VB.Menu mnuHelp
Caption = "帮助(&H)"
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub DynaMnu_Click(Index As Integer)
Dim FileNo As Long
FileNo = FreeFile
Open DynaMnu(Index).Caption For Input As #FileNo
TextEdit.Text = StrConv(InputB(LOF(FileNo), #FileNo), vbUnicode)
Close #FileNo
End Sub
Private Sub Form_Resize()
TextEdit.Width = Form1.ScaleWidth
TextEdit.Height = Form1.ScaleHeight
End Sub
Private Sub mnuExit_Click()
End
End Sub
Private Sub mnuFileClose_Click()
Me.Enabled = False
End Sub
Private Sub mnuFileOpen_Click()
On Error Resume Next ' 设置错误处理
Dim FileNo As Long
CommonDialog1.CancelError = True
CommonDialog1.Filter = "文本文件|*.txt|所有文件|*.*"
CommonDialog1.InitDir = "C:\My Documents"
CommonDialog1.Flags = &H200000 ' 允许使用长文件名
CommonDialog1.ShowOpen
If Err.Number = 32755 Then Exit Sub ' 若按取消按钮,则退出过程
Filename = CommonDialog1.Filename ' 将要打开的文件名保存于变量中
FileNo = FreeFile
Open Filename For Input As #FileNo ' 打开文件
' 下面在TextEdit文本框中显示文件的内容
TextEdit.Text = StrConv(InputB(LOF(FileNo), #FileNo), vbUnicode)
Close #FileNo ' 关闭文件
' 下面将文件添加记录到动态菜单中
For n = 1 To MnuItemNum ' 检查是否已有同名项
If DynaMnu(n).Caption = Filename Then ' 若已有同名的,则不添加
Exit Sub
End If
Next
MnuItemNum = MnuItemNum + 1
Load DynaMnu(MnuItemNum)
DynaMnu(MnuItemNum).Caption = Filename
DynaMnu(MnuItemNum).Visible = True
DynaBar.Visible = True
End Sub
Private Sub mnuFileSaveAs_Click()
On Error Resume Next
Dim FileNo As Long
CommonDialog1.CancelError = True
CommonDialog1.Filter = "文本文件|*.txt|所有文件|*.*"
CommonDialog1.InitDir = "C:\My Documents"
CommonDialog1.Flags = &H200000
CommonDialog1.ShowSave
If Err.Number = 32755 Then Exit Sub
Filename = CommonDialog1.Filename ' 获得要保存的文件名
FileNo = FreeFile
Open Filename For Output As #FileNo ' 以写的方式打开文件
Print #FileNo, TextEdit.Text ' 将内容写入文件
Close #FileNo ' 关闭文件
' 下面将文件添加记录到动态菜单中
For n = 1 To MnuItemNum
If DynaMnu(n).Caption = Filename Then Exit Sub
Next
MnuItemNum = MnuItemNum + 1
Load DynaMnu(MnuItemNum)
DynaMnu(MnuItemNum).Caption = Filename
DynaMnu(MnuItemNum).Visible = True
DynaBar.Visible = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -