开发工具:
文件大小: 932byte
下载次数: 0
上传时间: 2010-06-24
详细说明: Private Sub AxWindowsMediaPlayer1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Public Class Form1 Private Sub 文件ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Private Sub MenuItem15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditCopy.Click rtBook.Copy() End Sub Private Sub MenuItem16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditPaste.Click rtBook. Paste() '粘贴操作 End Sub Private Sub rtBook_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rtBook.TextChanged fsave = False '控件中的内容发生变化时,该标志为False End Sub Dim fsave As Boolean Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load '为全局变量赋值 '对保存文件对话框赋初值 SaveFileDialog1.FileName = "" SaveFileDialog1.DefaultExt = "txt" SaveFileDialog1.Filter = "Text File(*.txt)|*.txt|All files(*.*)|*.*" SaveFileDialog1.Title = "保存" '对打开文件对话框赋初值 OpenFileDialog1.FileName = "" OpenFileDialog1.DefaultExt = "txt" OpenFileDialog1.Filter = "Text File(*.txt)|*.txt|All files(*.*)|*.*" OpenFileDialog1.Title = "打开" End Sub Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileNew.Click Dim num1 As Integer '如果文本已被保存,则清空rtBook内容,重置变量新建文本 If fsave Then rtBook.Clear() SaveFileDialog1.FileName = "" '文件如果还没有保存,则询问用户如何处理 Else num1 = MsgBox("文件的内容已被改变。想保存文件吗?", vbYesNoCancel + 48, "记事本") Select Case num1 '用户选择保存,而且该文件从未保存过,则执行保存文件的操作 Case 6 If SaveFileDialog1.FileName = "" Then If SaveFileDialog1.ShowDialog Then rtBook.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If '如果该文件已存在,则弹出对话框,要求用户回答后再保存 End If '清空RTbook的内容,重置变量新建文本 fsave = True rtBook.Clear() SaveFileDialog1.FileName = "" Case 7 '如果用户选择不保存,则立即清空RTbook的内容,新建文本 rtBook.Clear() SaveFileDialog1.FileName = "" fsave = True Case Else '用户选择取消操作,则什么也不做,取消这次的新建操作 End Select End If End Sub Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileOpen.Click Dim num1 As Integer '如果文件内容还未保存,则弹出对话框,询问用户如何处理 If Not fsave Then num1 = MsgBox("文件的内容已被改变。想要保存文件吗?", vbYesNoCancel + 48, "记事本") Select Case num1 Case 6 '用户选择保存操作,而且该文件从未保存过,则输入文件名后进行保存 If SaveFileDialog1.FileName = "" Then If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If Else '若该文件已存在,则弹出对话框,用户选择保存后,直接保存 rtBook.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If '弹出【打开】对话框,执行打开文件的操作 fsave = True If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If Case 7 '用户选择不保存文件,则直接打开文本文件 If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText) fsave = True End If Case Else '用户选择了取消操作 End Select Else '文本已被保存,直接打开文件进行操作 If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If fsave = True End If End Sub Private Sub MenuItem8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileSave.Click If SaveFileDialog1.FileName = "" Then '如果文件从未保存过,则弹出对话框,输入文件名后,直接保存 If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If Else '若该文件以保存过,则弹出对话框后,用户选择保存后,直接保存到原文件中 rtBook.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText) End If fsave = True End Sub Private Sub MenuItem9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileSaveAs.Click '现将保存对话框的标题改为“另存为” SaveFileDialog1.Title = "另存为" If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText) fsave = True End If '文件保存完成后,对话框标题再改为“另存” SaveFileDialog1.Title = "保存" End Sub Private Sub MenuItem11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuExit.Click Close() End Sub Private Sub MenuItem12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditUndo.Click rtBook.Undo() '用户撤消操作 End Sub Private Sub MenuItem14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditCut.Click rtBook.Cut() '剪切操作 End Sub Private Sub MenuItem19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditSelectAll.Click rtBook.SelectAll() '全选操作 End Sub Private Sub MenuItem17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuEditDelete.Click rtBook.Cut() End Sub Private Sub MenuItem20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFont.Click If FontDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.Font = FontDialog1.Font '用户选择字体 End If End Sub Private Sub MenuItem21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuBackcolor.Click If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.ForeColor = ColorDialog1.Color '选择文本的颜色 End If End Sub Private Sub MenuItem22_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuForeColor.Click If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtBook.BackColor = ColorDialog1.Color '选择文本框的背景颜色 End If End Sub Private Sub MenuItem23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuHelpAbout.Click Dim 关于记事本 As Integer 关于记事本 = MsgBox("我的记事本 版本:1.0 版权所有(李振,吕红飞) 2004 http://www.hbsi.com.cn") End Sub ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.