求vb高手,高分悬赏!

设计简单的文档编辑器对.txt等文件进行操作,实现类似与记事本的功能要求:1.利用菜单编辑器建立菜单(至少包含“文件”、“编辑”、“字体”和“关于”四项主菜单项)1)在“... 设计简单的文档编辑器对.txt等文件进行操作,实现类似与记事本的功能
要求:
1. 利用菜单编辑器建立菜单(至少包含“文件”、“编辑”、“字体”和“关于”四项主菜单项)
1) 在“文件”下设置“新建”、“打开”、“保存”和“退出”四个子菜单项(利用CommonDialog控件),并分别完成相应功能
2) 在“编辑”下设置“剪切”、“复制”、“粘贴”、全选和“删除”等个子菜单项,并完成相应功能(注意剪贴板对象Clipboard的使用)。注意功能的配合使用,如必须在剪切版不为空的情况下才能够进行“粘贴”操作等,并建立相应的快捷键
3) 在“字体”下能够通过字体对话框来改变字体样式及大小。有如下效果:

4) 在“关于”菜单下显示关于记事本的相关信息,有如下效果。其中左侧的picturebox中放置自己随意选择的图片(呵呵,最好是自己的照片哦)。学号+姓名一定要与自己的相对应

2.添加状态栏:在状态栏Panels的第一个元素中始终显示自己的学号和姓名,在Panels第二个元素中实时显示系统时间(即当前时间)
编辑好了就发到我邮箱吧~939187404@qq.com~(*^__^*)
展开
 我来答
c20090218
2010-12-05 · TA获得超过255个赞
知道答主
回答量:161
采纳率:0%
帮助的人:195万
展开全部
算我一份。
主要代码如下:

Option Explicit

Dim Changed As Boolean

Dim FN As String 'Filename

Private Sub Form_Load()
Timer1_Timer

SB.Panels(1).Text = "你的学号+姓名写在此处"
End Sub

Private Sub Form_Resize()
T.Height = Me.ScaleHeight - SB.Height
T.Width = Me.ScaleWidth
End Sub

Private Sub Form_Unload(Cancel As Integer)
If Changed Then
Dim iRet As VbMsgBoxResult
iRet = MsgBox("您的文档已经修改,是否保存?", vbQuestion + vbYesNoCancel)
If iRet = vbYes Then
If Len(FN) > 0 Then 'Has a filename
Open FN For Output As #1
Print #1, T.Text;
Close #1
Changed = False
Else
CD.DialogTitle = "保存"
CD.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*"
CD.ShowSave
If Len(CD.FileName) > 0 Then 'Not canceled
Open CD.FileName For Output As #1
Print #1, T.Text;
Close #1
Else
Cancel = 1
End If
End If
ElseIf iRet = vbCancel Then
Cancel = 1
End If
End If
End Sub

Private Sub mnuEditCopy_Click()
Clipboard.SetText T.SelText
End Sub

Private Sub mnuEditCut_Click()
Clipboard.SetText T.SelText
T.SelText = ""
End Sub

Private Sub mnuEditFont_Click()
CD.Flags = CD.Flags Or cdlCFEffects
CD.Flags = CD.Flags Or cdlCFBoth
CD.ShowFont
T.ForeColor = CD.Color
T.FontBold = CD.FontBold
T.FontItalic = CD.FontItalic
T.FontUnderline = CD.FontUnderline
T.FontStrikethru = CD.FontStrikethru
T.FontName = CD.FontName
T.FontSize = CD.FontSize
End Sub

Private Sub mnuEditPaste_Click()
T.SelText = Clipboard.GetText
End Sub

Private Sub mnuFileExit_Click()
Unload Me
End Sub

Private Sub mnuFileNew_Click()
If Changed Then
Dim iRet As VbMsgBoxResult
iRet = MsgBox("您的文档已经修改,是否保存?", vbQuestion + vbYesNoCancel)
If iRet = vbYes Then
If Len(FN) > 0 Then 'Has a filename
Open FN For Output As #1
Print #1, T.Text;
Close #1
Changed = False
Else
CD.DialogTitle = "保存"
CD.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*"
CD.ShowSave
If Len(CD.FileName) > 0 Then 'Not canceled
Open CD.FileName For Output As #1
Print #1, T.Text;
Close #1
Changed = False
End If
End If
ElseIf iRet = vbNo Then
FN = ""
Changed = False
End If
End If
T.Text = ""
End Sub

Private Sub mnuFileOpen_Click()
If Changed Then
Dim iRet As VbMsgBoxResult
iRet = MsgBox("您的文档已经修改,是否保存?", vbQuestion + vbYesNoCancel)
If iRet = vbYes Then
If Len(FN) > 0 Then 'Has a filename
Open FN For Output As #1
Print #1, T.Text;
Close #1
Else
CD.DialogTitle = "保存"
CD.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*"
CD.ShowOpen
If Len(CD.FileName) > 0 Then 'Not canceled
Open CD.FileName For Output As #1
Print #1, T.Text;
Close #1
T.Text = ""
End If
End If
ElseIf iRet = vbNo Then
FN = ""
T.Text = ""
End If
End If
CD.DialogTitle = "打开"
CD.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*"
CD.Flags = CD.Flags Or cdlOFNHideReadOnly
CD.ShowOpen
If Len(CD.FileName) > 0 Then
Dim TempStr As String
Open CD.FileName For Input As #2
Do While Not EOF(2)
Line Input #2, TempStr
T.Text = T.Text & TempStr & vbCrLf
Loop
T.Text = Left$(T.Text, Len(T.Text) - 2) 'No Cr+Lf here
Close #2
FN = CD.FileName
End If
Changed = False
End Sub

Private Sub mnuFileSave_Click()
If Len(FN) = 0 Then
mnuFileSaveAs_Click
Else
Open FN For Output As #1
Print #1, T.Text;
Close #1
End If
End Sub

Private Sub mnuFileSaveAs_Click()
CD.DialogTitle = "另存为"
CD.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*"
CD.ShowSave
If Len(CD.FileName) > 0 Then
Open CD.FileName For Output As #1
Print #1, T.Text;
Close #1
Changed = False
FN = CD.FileName
End If
End Sub

Private Sub mnuHelpAbout_Click()
fAbout.Show vbModal
End Sub

Private Sub T_Change()
Changed = True
End Sub

Private Sub Timer1_Timer()
SB.Panels(2).Text = Time$
End Sub

Private Sub Timer2_Timer()
If Clipboard.GetFormat(vbCFText) Then
mnuEditPaste.Enabled = True
Else
mnuEditPaste.Enabled = False
End If
If T.SelLength > 0 Then
mnuEditCut.Enabled = True
mnuEditCopy.Enabled = True
Else
mnuEditCut.Enabled = False
mnuEditCopy.Enabled = False
End If
End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式