?? form1.frm
字號:
VERSION 5.00
Begin VB.Form frmEdit
Caption = "文本編輯器"
ClientHeight = 3345
ClientLeft = 165
ClientTop = 735
ClientWidth = 5385
LinkTopic = "Form1"
ScaleHeight = 3345
ScaleWidth = 5385
StartUpPosition = 3 'Windows Default
Begin VB.TextBox txtEdit
Height = 1695
Left = 480
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 0
Top = 360
Width = 3015
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 mnuFileSave
Caption = "保存(&S)"
Shortcut = ^S
End
Begin VB.Menu mnuFileSaveAs
Caption = "另存為...(&A)"
End
Begin VB.Menu numFileSeparator
Caption = "-"
End
Begin VB.Menu mnuFileExit
Caption = "退出(&E)"
End
End
End
Attribute VB_Name = "frmEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim strFileName As String '文件名
Dim blnModified As Boolean '保存后是否編輯過
Private Sub Form_Load()
Caption = "文本編輯器"
End Sub
Private Sub Form_Resize() '使文本框占據整個窗體的客戶區
txtEdit.Top = 0: txtEdit.Left = 0
txtEdit.Width = ScaleWidth: txtEdit.Height = ScaleHeight
End Sub
Private Sub mnuFileNew_Click() '新建文件
Dim int1 As Integer
If blnModified Then '如果有未保存的文件,提示保存
int1 = MsgBox("新建文件前是否保存當前文件?", 35, "注意")
If int1 = 6 Then
SaveFile '保存文件
ElseIf int1 = 2 Then
Exit Sub
End If
End If
Caption = "文本編輯器"
txtEdit.Text = ""
strFileName = ""
blnModified = False
End Sub
Private Sub mnuFileOpen_Click() '打開文件
Dim strTemp1 As String, strTemp2 As String
Dim int1 As Integer
If blnModified Then '如果有未保存的文件,提示保存
int1 = MsgBox("打開新文件前是否保存當前文件?", 35, "是否保存")
If int1 = 6 Then
SaveFile '保存文件
ElseIf int1 = 2 Then
Exit Sub
End If
End If
strTemp1 = InputBox("請輸入要打開的完整文件名:", "文件名") '輸入文件名
If strTemp1 = "" Then
Exit Sub
Else
strFileName = strTemp1
Caption = "文本編輯器:" & strFileName '改變窗體標題
Open strFileName For Input As 1 '從文件中讀入文本
Do While Not EOF(1)
Line Input #1, strTemp1 '整行讀入
strTemp2 = strTemp2 & strTemp1 & Chr(13) & Chr(10) '行尾加回車和換行
Loop
Close 1
txtEdit.Text = strTemp2
blnModified = False
End If
End Sub
Private Sub mnuFileSave_Click()
SaveFile '保存文件
End Sub
Private Sub mnuFileSaveAs_Click() '另存為
Dim strTemp As String
strTemp = InputBox("請輸入完整文件名:", "文件名")
If strTemp = "" Then
Exit Sub
Else
strFileName = strTemp
Caption = "文本編輯器:" & strFileName
SaveFile
End If
End Sub
Private Sub SaveFile() '保存文件
If strFileName = "" Then
strFileName = InputBox("請輸入被保存文件的完整文件名:", "文件名")
If strFileName = "" Then
Exit Sub
End If
Caption = "文本編輯器:" & strFileName
End If
Open strFileName For Output As 1
Print #1, txtEdit.Text
Close 1
blnModified = False
End Sub
Private Sub mnuFileExit_Click()
Unload Me
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim int1 As String
If blnModified Then
int1 = MsgBox("文件尚未保存,退出時是否保存?", 35, "注意")
If int1 = 6 Then
SaveFile
ElseIf int1 = 2 Then
Cancel = 1
End If
End If
End Sub
Private Sub txtEdit_Change()
blnModified = True
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -