?? text.frm
字號:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "Comdlg32.ocx"
Begin VB.Form Form1
Caption = "記事本"
ClientHeight = 5070
ClientLeft = 2415
ClientTop = 2460
ClientWidth = 7320
LinkTopic = "Form1"
ScaleHeight = 5070
ScaleWidth = 7320
StartUpPosition = 2 '屏幕中心
Begin MSComDlg.CommonDialog Dialog
Left = 6120
Top = 2880
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.TextBox Text
Height = 4815
Left = 120
MousePointer = 3 'I-Beam
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 0
Top = 0
Width = 5535
End
Begin VB.Image Image1
Height = 2385
Left = 6000
Picture = "text.frx":0000
Top = 120
Visible = 0 'False
Width = 1695
End
Begin VB.Menu Item_File
Caption = "文件(&F)"
Begin VB.Menu Item_New
Caption = "新建(&N)"
End
Begin VB.Menu Item_open
Caption = "打開(&O)"
End
Begin VB.Menu Item_Save
Caption = "保存(&S)"
End
Begin VB.Menu Item_SaveAs
Caption = "另存為(&A)"
End
Begin VB.Menu Item_11
Caption = "-"
End
Begin VB.Menu Item_Exit
Caption = "退出(&X)"
End
End
Begin VB.Menu Item_Edit
Caption = "編輯(&E)"
Begin VB.Menu Item_Cut
Caption = "剪切(&T)"
Shortcut = ^X
End
Begin VB.Menu Item_Copy
Caption = "復制(&C)"
Shortcut = ^C
End
Begin VB.Menu Item_Paste
Caption = "粘貼(&P)"
Shortcut = ^V
End
Begin VB.Menu Item_Delete
Caption = "刪除(&L)"
Shortcut = {DEL}
End
Begin VB.Menu Item_DateTime
Caption = "時間\日期(&D)"
Shortcut = {F5}
End
End
Begin VB.Menu Item_Search
Caption = "搜索(&S)"
Begin VB.Menu Item_find
Caption = "查找(&F)"
End
Begin VB.Menu Item_FindNext
Caption = "查找下一個(&N)"
Shortcut = {F3}
End
End
Begin VB.Menu Item_Help
Caption = "幫助(&H)"
Begin VB.Menu Item_HelpTopic
Caption = "幫助主題(&H)"
End
Begin VB.Menu Item_41
Caption = "-"
End
Begin VB.Menu Item_About
Caption = "關于記事本(&A)"
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Modified As Boolean
Public FindPos As Long
Public FindStr As String
Public FileName As String
Private Exist As Boolean
Private IsSaved As Boolean
Private Sub Form_Load()
Modified = False
IsSaved = False
FindPos = 1
FindStr = ""
Exist = False
FileName = "無標題"
Caption = FileName + "-記事本"
Item_Cut.Enabled = False
Item_Copy.Enabled = False
If Clipboard.GetFormat(vbCFText) Then
Item_Paste.Enabled = True
Else
Item_Paste.Enabled = False
End If
Item_FindNext.Enabled = False
Form_Resize
End Sub
Private Sub Form_Resize()
Text.Top = Me.ScaleTop
Text.Left = Me.ScaleLeft
Text.Width = Me.ScaleWidth
Text.Height = Me.ScaleHeight
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim Result As Integer
If Exist = True Then
If Modified = True Then
Result = MsgBox("文件已被修改,是否保存?", vbYesNo Or vbQuestion, "警告")
If IsSaved = True Then
If Result = vbYes Then
Item_Save_Click
End If
ElseIf Result = vbYes Then
Item_SaveAs_Click
End If
End If
End If
Unload Me
End Sub
Private Sub Item_About_Click()
Dim ID As Long
ID = ShellAbout(Me.hwnd, "關于記事本#記事本", "", Image1.Picture.Handle)
End Sub
Private Sub Item_Copy_Click()
Clipboard.SetText (Text.SelText)
If Clipboard.GetFormat(vbCFText) Then
Item_Paste.Enabled = True
Item_Cut.Enabled = False
Item_Copy.Enabled = False
Else
Item_Paste.Enabled = False
Item_Cut.Enabled = True
Item_Copy.Enabled = True
End If
End Sub
Private Sub Item_Cut_Click()
Clipboard.SetText (Text.SelText)
Text.SelText = ""
If Clipboard.GetFormat(vbCFText) Then
Item_Paste.Enabled = True
Item_Cut.Enabled = False
Item_Copy.Enabled = False
Else
Item_Paste.Enabled = False
Item_Cut.Enabled = True
Item_Copy.Enabled = True
End If
End Sub
Private Sub Item_DateTime_Click()
Dim NewTime As Date
Dim NewDate As Date
Dim Temp As String
NewTime = Time
NewDate = Date
Temp = Text.SelText
Text.SelText = NewTime + NewDate
Text.SelText = Temp
End Sub
Private Sub Item_Delete_Click()
If Text.SelLength <> 0 Then
Text.SelText = ""
End If
End Sub
Private Sub Item_Exit_Click()
Unload Me
End Sub
Private Sub Item_Find_Click()
Dim DesStr As String
FindStr = InputBox("請輸入要搜索的字符串...", "輸入搜索字符串", Text.SelText)
DesStr = Text.Text
If Len(FindStr) > 0 Then
If FindPos <= 0 Then FindPos = 1
FindPos = InStr(FindPos, DesStr, FindStr, vbTextCompare)
If FindPos >= 1 Then
MsgBox ("找到字符串在" + Str(FindPos) + "的位置上!")
Item_FindNext.Enabled = True
FindPos = FindPos + Len(FindStr)
If FindPos >= Len(DesStr) Then
FindPos = 1
MsgBox = ("沒有找到您要查找的字符串!")
End If
Else
MsgBox ("沒有找到您要查找的字符串!")
End If
End If
End Sub
Private Sub Item_FindNext_Click()
Dim DesStr As String
DesStr = Text.Text
If FindPos <= 0 Then FindPos = 1
FindPos = InStr(FindPos, DesStr, FindStr, vbTextCompare)
If FindPos >= 1 Then
MsgBox ("找到字符串在" + Str(FindPos) + "的位置上!")
FindPos = FindPos + Len(FindStr)
If FindPos >= Len(DesStr) Then
FindPos = 1
MsgBox ("沒有找到您要查找的字符串!")
End If
Else
MsgBox ("沒有找到您要查找的字符串!")
End If
End Sub
Private Sub Item_New_Click()
Dim Result As Integer
Dim Msg As String
Msg = "文件" + FileName + "的正文已更改." + Chr(13) + "是否保存更改?" + Chr(13)
If Exist = True Then
If Modified = True Then
Result = MsgBox(Msg, vbYesNoCancel + vbExclamation + vbDefaultButton1, "記事本")
If Result = vbYes Then
If IsSaved = True Then
Iten_Save_Click
Else
Iten_SaveAs_Click
End If
Text.Text = ""
Modified = False
Exist = True
IsSaved = False
FindPos = 1
FindStr = ""
FileName = "無標題"
Caption = FileName + "-記事本"
Item_Cut.Enabled = False
Item_Copy.Enabled = False
If Clipboard.GetFormat(vbCFText) Then
Item_Paste.Enabled = True
Else
Item.Paste.Enabled = False
End If
Item_FindNext.Enabled = False
ElseIf Result = vbNo Then
Item_Cut.Enabled = False
Item_Copy.Enabled = False
If Clipboard.GetFormat(vbCFText) Then
Item_Paste.Enabled = True
Else
Item_Paste.Enabled = False
End If
Item_FindNext.Enabled = False
Text.Text = ""
Modified = False
Exist = True
IsSaved = False
FinfPos = 1
FindStr = ""
FindName "無標題"
Caption = FileName + "-記事本"
End If
Else
Text.Text = ""
Modified = False
Exist = True
IsSaved = False
FindPos = 1
FindStr = ""
FileName = "無標題"
Caption = FileName + "-記事本"
End If
End If
End Sub
Private Sub Item_open_Click()
Dim Result As Integer
Dim Msg As String
Dim NewText As String
If Exist = True Then
If Modified = True Then
Msg = "文件" + FileName + "的正文已更改." + Chr(13) + "是否保存更改?" + Chr(13)
Result = MsgBox(Msg, vbYesNoCancel + vbExclamation + vbDefaultButton1, "記事本")
If Result = vbYes Then
If IsSaved = True Then
Item_Save_Click
Else
Item_SaveAs_Click
End If
End If
If Result = vbCancel Then
Exit Sub
End If
End If
End If
Dialog.Filter = "文本文件(*.TXT)|*.txt"
Dialog.FileName = ""
Dialog.ShowOpen
If Len(Dialog.FileName) = 0 Then
Exit Sub
End If
FileName = Dialog.FileName
Open FileName For Input As #1
Text.Text = ""
Input #1, NewText
Text.Text = NewText
Close #1
Exist = True
IsSaved = True
Modified = False
FindPos = 1
FindStr = ""
Caption = FileName + "-記事本"
End Sub
Private Sub Item_Paste_Click()
If Clipboard.GetFormat(vbCFText) Then
Text.SelText = Clipboard.GetText
End If
End Sub
Private Sub Item_Save_Click()
Open FileName For Output As #1
Write #1, Text.Text
Close #1
IsSaved = True
Modified = False
Caption = FileName + "-記事本"
End Sub
Private Sub Item_SaveAs_Click()
Dialog.Filter = "文本文件(*.TXT)|*.txt"
Dialog.FileName = FileName
Dialog.ShowSave
If Len(Dialog.FileName) = 0 Then
Exit Sub
End If
FileName = Dialog.FileName
Open FileName For Output As #1
Write #1, Text.Text
Close #1
IsSaved = True
Modified = False
Caption = FileName + "-記事本"
End Sub
Private Sub Text_Change()
Modified = True
Exist = True
If Clipboard.GetFormat(vbCFText) Then
If Text.SelText <> "" Then
Item_Cut.Enabled = True
Item_Copy.Enabled = True
Item_Paste.Enabled = True
Else
Item_Cut.Enabled = False
Item_Copy.Enabled = False
Item_Paste.Enabled = True
End If
Else
Item_Cut.Enabled = True
Item_Copy.Enabled = True
Item_Paste.Enabled = False
End If
Item_Delete.Enabled = True
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -