VB语言设计厉害的进
菜单编辑器
文件 编辑 格式 帮助
新建 复制 字体 关于(随便弄)
打开 粘贴 字号
保存 删除
另存为
退出
请用richtextbox做文本框,其中字体只要“黑体”和“宋体”,字号三个就行 展开
Dim filename As String
Private Sub bz_Click()
On Error GoTo err
If RichTextBox1.Text = "" Then
CommonDialog1.Filter = "文档文件(*.txt)|*.txt|所有文件(*.*)|*.*"
CommonDialog1.ShowSave
Open CommonDialog1.filename For Output As #1
Print #1, RichTextBox1.Text
Close 1
Else
Open filename For Output As #1
Print #1, RichTextBox1.Text
Close 1
End If
err:
End Sub
Private Sub dk_Click()
On Error GoTo Err_Handle
CommonDialog1.ShowOpen
filename = CommonDialog1.filename
RichTextBox1.Text = ""
If (Len(filename) > 0) Then
RichTextBox1.LoadFile (filename)
End If
Exit Sub
Err_Handle:
Exit Sub
End Sub
Private Sub es_Click()
RichTextBox1.Font.Size = 20
End Sub
Private Sub Form_Load()
With CommonDialog1
.MaxFileSize = 100
.CancelError = True
.Filter = "文件类型(*.txt)|*.txt"
.DialogTitle = "请选择一个TXT格式文件"
.InitDir = "C:\"
.Flags = cdlOFNFileMustExist Or cdlOFNReadOnly
End With
End Sub
Private Sub Form_Resize()
RichTextBox1.Width = Me.ScaleWidth
RichTextBox1.Height = Me.ScaleHeight
End Sub
Private Sub fz_Click()
Clipboard.SetText Form1.RichTextBox1.SelText, 1
End Sub
Private Sub ht_Click()
RichTextBox1.Font.Name = "黑体"
End Sub
Private Sub jq_Click()
Clipboard.SetText Form1.RichTextBox1.SelText, 1
Form1.RichTextBox1.SelText = ""
End Sub
Private Sub lcw_Click()
On Error GoTo err
CommonDialog1.Filter = "文档文件(*.rtf)|*.rtf|所有文件(*.*)|*.*"
CommonDialog1.DialogTitle = "另存为"
CommonDialog1.ShowSave
Open CommonDialog1.filename For Output As #1
Print #1, RichTextBox1.Text
Close 1
err:
End Sub
Private Sub nt_Click()
i = Form1.RichTextBox1.SelStart
str1 = Mid(Form1.RichTextBox1.Text, 1, i)
str2 = Mid(Form1.RichTextBox1.Text, _
Form1.RichTextBox1.SelStart + 1, _
Len(Form1.RichTextBox1) - Len(str1))
Form1.RichTextBox1 = str1 & Clipboard.GetText & str2
End Sub
Private Sub sc_Click()
Form1.RichTextBox1.SelText = ""
End Sub
Private Sub sh_Click()
RichTextBox1.Font.Size = 10
End Sub
Private Sub ss_Click()
RichTextBox1.Font.Size = 30
End Sub
Private Sub st_Click()
RichTextBox1.Font.Name = "宋体"
End Sub
Private Sub tc_Click()
End
End Sub
Private Sub xj_Click()
If MsgBox("是否保存该文件", vbOKCancel + vbInformation, "提示") = vbCancel Then
RichTextBox1.Text = ""
Else
CommonDialog1.Filter = "文档文件(*.txt)|*.txt|所有文件(*.*)|*.*"
CommonDialog1.ShowSave
Open CommonDialog1.filename For Output As #1
Print #1, RichTextBox1.Text
Close 1
End If
End Sub
Dim a As Integer
Private Sub 保存_Click()
Open "c:\test.txt" For Output As #1
Print #1, RichTextBox1.Text
Close #1
End Sub
Private Sub 打开_Click()
on error goto a
CommonDialog1.Filter = "文本文件(*.txt)|*.txt"
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Input As #1
Line Input #1, s1
RichTextBox1.Text = s1
Close #1
a:
End Sub
Private Sub 复制_Click()
SendKeys "^c"
End Sub
Private Sub 关于_Click()
RichTextBox1.Text = "本软件是爱好公司制作,谢谢使用"
End Sub
Private Sub 黑体_Click()
RichTextBox1.Font.Name = "黑体"
End Sub
Private Sub 另存为_Click()
on error goto a
CommonDialog1.Filter = "文本文件| *.txt"
CommonDialog1.ShowSave
Open CommonDialog1.FileName For Output As #1
Print #1, RichTextBox1.Text
Close #1
a:
End Sub
Private Sub 删除_Click()
RichTextBox1.Text = ""
End Sub
Private Sub 宋体_Click()
RichTextBox1.Font.Name = "宋体"
End Sub
Private Sub 退出_Click()
End
End Sub
Private Sub 新建_Click()
RichTextBox1.Text = ""
End Sub
Private Sub 粘贴_Click()
SendKeys "^v"
End Sub
Private Sub 字号_Click()
a = a + 10
RichTextBox1.Font.Size = a
End Sub