新建功能:
Private Sub xinjian_Click()
Dim a As String
Dim b As Integer
a = "文件" + Caption + "的文字已经改变。" + Chr(13) + "想保存文件吗?"
If Text1.Text > "" Then b = MsgBox(a, vbApplicationModal + vbDefaultButton1 + vbYesNoCancel + vbExclamation, "记事本")
Select Case b
Case 6
CommonDialog1.CancelError = True
On Error GoTo errhandler
CommonDialog1.DialogTitle = "另存为"
CommonDialog1.InitDir = "c:\windows"
CommonDialog1.FileName = "*.txt"
CommonDialog1.Filter = "text files(*.txt)|*.txt"
CommonDialog1.ShowSave
Open CommonDialog1.FileName For Output As #1
Print #1, Mid(Text1.Text, 1, Len(Text1.Text))
Close #1
Text1.Text = ""
errhandler:
Exit Sub
Case 7
Text1.Text = ""
Exit Sub
End Select
End Sub
另存为功能:
Private Sub lingcunwei_Click()
CommonDialog1.CancelError = True
On Error GoTo errhandler
CommonDialog1.DialogTitle = "另存为"
CommonDialog1.InitDir = "c:\windows"
CommonDialog1.FileName = "*.txt"
CommonDialog1.Filter = "text files(*.txt)|*.txt"
CommonDialog1.ShowSave
Open CommonDialog1.FileName For Output As #1
Print #1, Mid(Text1.Text, 1, Len(Text1.Text))
Close #1
errhandler:
Exit Sub
End Sub
保存功能:
Private Sub baocun_Click()
CommonDialog1.CancelError = True
On Error GoTo errhandler
CommonDialog1.DialogTitle = "另存为"
CommonDialog1.InitDir = "c:\windows"
CommonDialog1.FileName = "*.txt"
CommonDialog1.Filter = "text files(*.txt)|*.txt"
CommonDialog1.ShowSave
Open CommonDialog1.FileName For Output As #1
Print #1, Mid(Text1.Text, 1, Len(Text1.Text))
Close #1
errhandler:
Exit Sub
End Sub
打开功能:
Private Sub dakai_Click()
CommonDialog1.CancelError = True
On Error GoTo errhandler
CommonDialog1.DialogTitle = "打开文本文件"
CommonDialog1.FileName = ""
CommonDialog1.InitDir = "c:windows"
CommonDialog1.Filter = "text files(*.text)|*.txt"
CommonDialog1.ShowOpen
If CommonDialog1.FileName > "" Then
Text1.Text = ""
Open CommonDialog1.FileName For Input As #1
Do While Not EOF(1)
Line Input #1, s
Text1.Text = Text1.Text + s + vbCrLf
Close #1
End If
errhandler:
Exit Sub
End Sub
打印功能:
Private Sub dayin_Click()
CommonDialog1.CancelError = True
On Error GoTo errhandler
CommonDialog1.Flags = 256
CommonDialog1.ShowPrinter
For i = 1 To CommonDialog1.Copies
Printer.Print Text1.Text
Next i
errhandler:
Exit Sub
End Sub
复制功能:
Private Sub fuzhi_Click()
Clipboard.Clear 'clipboard为剪切板
Clipboard.SetText Text1.SelText
End Sub
剪切功能:
Private Sub jianqie_Click()
Clipboard.Clear 'clipboard为剪切板
Clipboard.SetText Text1.SelText
Text1.Text = ""
End Sub
粘贴功能:
Private Sub niantie_Click()
Text1.SelText = Clipboard.GetText
End Sub
查找功能:
Private Sub chazhao_Click()
Dim pos As Integer
Dim t As String
t = InputBox$("请输入要查找的内容:", "查找")
Text1.SetFocus
pos = InStr(1, Text1.Text, t)
If pos > 0 Then
Text1.SelStart = pos - 1
Text1.SelLength = Len(t)
Else
MsgBox "没有找到您要查找的内容!", vbInformation, "记事本"
End If
End Sub
全选功能:
Private Sub quanxuan_Click()
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End Sub
删除功能:
Private Sub shanchu_Click()
Text1.SelText = ""
End Sub
时间/日期功能:
Private Sub shijian_Click()
a = Year(Date)
b = Month(Date)
c = Day(Date)
d = Hour(Time())
e = Minute(Time())
Text1.Text = Text1.Text + Str(a) + "-" + Str(b) + "-" + Str(c) + " " + Str(d) + ":" + Str(e)
End Sub
Private Sub tuichu_Click()
End
End Sub
--------------------------------------------------------
字体功能:
Private Sub ziti_Click()
CommonDialog1.Flags = cdlCFBoth Or cdlCFEffects
CommonDialog1.ShowFont
CommonDialog1.FontName = "宋体"
With Text1
.FontName = CommonDialog1.FontName
.FontSize = CommonDialog1.FontSize
.FontItalic = CommonDialog1.FontItalic
.FontStrikethru = CommonDialog1.FontStrikethru
.FontUnderline = CommonDialog1.FontUnderline
.ForeColor = CommonDialog1.Color
End With
End Sub
关于记事本功能:
Private Sub guanyujishiben_Click()
Form2.Show
End Sub
帮助主题功能:
Private Sub bangzhuzhuti_Click()
form3.Show
End Sub
界面如下: