Option Explicit
Dim filename As String
Dim FileType As String
Dim FiType As String
Dim sFind As String
Dim result As String
Dim bWrap As Boolean
Dim ask As Boolean
Dim msgtext As String
Dim Flag As String
Private Sub Form_Load()
ask = False
RichText.Text = ""
filename = "无标题-记事本"
Form1.Caption = "无标题-记事本"
RichText.Height = Form1.ScaleHeight
RichText.Width = Form1.ScaleWidth
StatusBar1.Visible = False
StatusBar1.Panels(1).Text = Time
mnucopy.Enabled = False
mnucut.Enabled = False
mnufound.Enabled = False
mnufoundnext.Enabled = False
mnudel.Enabled = False
mnucancel.Enabled = False
mnuwordwrap.Checked = True
mnugoto.Enabled = False
If Clipboard.GetText <>"" Then
mnuplaster.Enabled = True
Else
mnuplaster.Enabled = False
End If
App.HelpFile = App.Path &"\notepad.chm"
End Sub
Private Sub Form_Resize()
RichText.Height = Form1.ScaleHeight
RichText.Width = Form1.ScaleWidth
End Sub
Private Sub Form_Unload(Cancel As Integer)
msgtext = "文件" &filename &"的文字已经改变。" &Chr(10) &Chr(13) &"想保存文件吗?"
If ask = True Then
Flag = MsgBox(msgtext, 35, "记事本") ' 35=32+3
If Flag = vbYes Then mnusave_Click '选择了确定则保存之
If Flag = vbCancel Then Cancel = True
If Flag = vbNo Then Unload Me
End If
End Sub
Private Sub mnuabout_Click()
MsgBox "记事本", vbOKOnly, "关于"
End Sub
Private Sub mnuall_Click()
RichText.SelStart = 0
RichText.SelLength = Len(RichText.Text)
End Sub
Private Sub mnucancel_Click()
MsgBox "请点击鼠标右键撤销!", vbOKOnly, "提示"
End Sub
Private Sub mnucopy_Click()
Clipboard.Clear
Clipboard.SetText RichText.SelText
End Sub
Private Sub mnucut_Click()
Clipboard.Clear
Clipboard.SetText RichText.SelText
RichText.SelText = ""
End Sub
Private Sub mnudel_Click()
RichText.SelText = ""
End Sub
Private Sub mnuedit_Click()
If RichText.SelText <>"" Then
mnuopen.Enabled = True
mnucut.Enabled = True
mnudel.Enabled = True
mnucopy.Enabled = True
End If
If Len(RichText.Text) <>0 Then
mnufound.Enabled = True
mnufoundnext.Enabled = True
End If
If ask = True Then mnucancel.Enabled = True
End Sub
Private Sub mnuexit_Click()
Unload Me
End Sub
Private Sub mnufont_Click()
On Error Resume Next
CommonDialog1.flags = &H3 Or &H1 Or &H2 Or &H100
CommonDialog1.Action = 4
RichText.Font.Name = CommonDialog1.FontName
RichText.Font.Size = CommonDialog1.FontSize
RichText.Font.Bold = CommonDialog1.FontBold
RichText.Font.Italic = CommonDialog1.FontItalic
RichText.Font.Underline = CommonDialog1.FontUnderline
RichText.SelColor = CommonDialog1.Color
End Sub
Private Sub mnufound_Click()
sFind = InputBox("请输入要查找的字、词:", "查找内容", sFind)
RichText.Find sFind
End Sub
Private Sub mnufoundnext_Click()
RichText.SelStart = RichText.SelStart + RichText.SelLength + 1
RichText.Find sFind, , Len(RichText)
End Sub
Private Sub mnuhelptopic_Click()
SendKeys "{F1}"
End Sub
Private Sub mnunewfile_Click()
On Error Resume Next
Dim n As Integer
msgtext = "文件" &filename &"的文字已经改变。" &Chr(10) &Chr(13) &"想保存文件吗?"
If Len(RichText.Text) <>0 Then
If filename = "无标题-记事本" Then
Flag = MsgBox(msgtext, 35, "记事本") '给予提示
If Flag = vbYes Then
mnusaveas_Click
RichText.Text = ""
Form1.Caption = "无标题-记事本"
filename = "无标题-记事本"
End If
If Flag = vbCancel Then Exit Sub
If Flag = vbNo Then
RichText.Text = ""
Form1.Caption = "无标题-记事本"
filename = "无标题-记事本"
End If
End If
End If
End Sub
Private Sub mnuopen_Click()
msgtext = "文件" &filename &"的文字已经改变。" &Chr(10) &Chr(13) &"想保存文件吗?"
On Error Resume Next
If ask = True Then
Flag = MsgBox(msgtext, 35, "记事本") '给予提示
If Flag = vbYes Then mnusave_Click '选择了确定则保存之
If Flag = vbCancel Then Exit Sub
If Flag = vbNo Then GoTo L1
End If
ask = False
L1: CommonDialog1.Filter = "文本文档(*.txt)|*.txt|RTF文档(*.rtf)|*.rtf|所有文件(*.*)|*.*"
CommonDialog1.ShowOpen
RichText.Text = "" '清空文本框
filename = CommonDialog1.filename
RichText.LoadFile filename
result = GetFileTitle(filename)
Me.Caption = "" &result &"-记事本"
End Sub
Private Sub mnupagesetup_Click()
psdlg.lStructSize = Len(psdlg)
psdlg.hwndOwner = hwnd
PageSetupDlg psdlg
End Sub
Private Sub mnuplaster_Click()
RichText.SelText = Clipboard.GetText(1)
End Sub
Private Sub mnuprint_Click()
Dim f As Integer, t As Integer
Dim i As Integer
CommonDialog1.CancelError = True
CommonDialog1.Max = 1000
CommonDialog1.Min = 1
On Error Resume Next
CommonDialog1.ShowPrinter
For f = CommonDialog1.FromPage To t = CommonDialog1.ToPage
Do While i <CommonDialog1.Copies + 1
Printer.Print RichText.Text
i = i + 1
Loop
Next
Printer.EndDoc
Cancel:
If Err.Number = 32755 Then
Exit Sub
End If
End Sub
Private Sub mnusave_Click()
CommonDialog1.Filter = "文本文档(*.txt)|所有文件(*.*)|*.*"
On Error Resume Next
filename = CommonDialog1.filename '保存文件
If filename <>"" Then
RichText.SaveFile filename, rtfText
Else
mnusaveas_Click
End If
ask = False
End Sub
Private Sub mnusaveas_Click()
CommonDialog1.Filter = "文本文档(*.txt)|所有文件(*.*)|*.*"
On Error Resume Next
CommonDialog1.ShowSave
filename = CommonDialog1.filename
RichText.SaveFile filename, rtfText
result = GetFileTitle(filename)
Me.Caption = "" &result &"-记事本"
ask = False
End Sub
Private Sub mnustatusbar_Click()
If mnustatusbar.Checked Then
StatusBar1.Visible = False
mnustatusbar.Checked = False
Else
StatusBar1.Visible = True
mnustatusbar.Checked = True
End If
End Sub
Private Sub mnutimedate_Click()
RichText.SelText = Format(Now, "h:mm ddddd")
End Sub
Private Sub mnuwordwrap_Click()
WrapTextLine RichText, bWrap
bWrap = Not bWrap
If mnuwordwrap.Checked = False Then
HScroll1.Enabled = True
mnuwordwrap.Checked = True
Else
HScroll1.Enabled = False
mnuwordwrap.Checked = False
End If
End Sub
Private Sub RichText_Change()
ask = True
End Sub
Private Sub Timer1_Timer()
If StatusBar1.Panels(1).Text <>CStr(Time) Then
StatusBar1.Panels(1).Text = Time
End If
End Sub
'模块代码
Option Explicit
Const WM_USER = &H400
Const EM_SETTARGETDEVICE = (WM_USER + 72)
Type POINTAPI
x As Long
y As Long
End Type
Type RECT
left As Long
right As Long
top As Long
bottom As Long
End Type
Public Type PageSetupDlg
lStructSize As Long
hwndOwner As Long
hDevMode As Long
hDevNames As Long
flags As Long
ptPaperSize As POINTAPI
rtMinMargin As RECT
rtMargin As RECT
hInstance As Long
lCustData As Long
lpfnPageSetupHook As Long
lpfnPagePaintHook As Long
lpPageSetupTemplateName As String
hPageSetupTemplate As Long
End Type
Public psdlg As PageSetupDlg
Declare Function PageSetupDlg Lib "comdlg32.dll" Alias "PageSetupDlgA" (pPagesetupdlg As PageSetupDlg) As Long
Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Dim bWrap As Boolean'// 换行标记'// 自定义一个换行的过程
Public Sub WrapTextLine(ByRef RichText As RichTextBox, ByVal bWrapSwitch As Boolean)
On Error Resume Next
If bWrapSwitch Then '// 设置 RichTextBox 自动换行
SendMessage RichText.hwnd, EM_SETTARGETDEVICE, GetDC(RichText.hwnd), RichText.Width / 15
RichText.RightMargin = IIf(RichText.RightMargin = 0, 1, 0)
Else
'// 设置 RichTextBox 不自动换行
SendMessage RichText.hwnd, EM_SETTARGETDEVICE, 0, 1
End If
End Sub
Function GetFileTitle(OldStr As String) As String
On Error Resume Next
Dim n As Integer, m As Integer '声明字符串变量
Dim i As String, r As String
Dim p As Integer
i = "\" '要查找的指定字符
For n = 1 To Len(OldStr) '用Len函数计算已知字符串的字节数
m = InStrRev(OldStr, i, -1) '"\"所在的位置(其中的-1是默认的)
Next n '找下去!
'截取最后一个"\"后面的字符串
r = right(OldStr, Len(OldStr) - m) '获取Title
p = InStrRev(r, ".", -1) '"."所在位置
GetFileTitle = left(r, p - 1) '去掉后缀
End Function
vb编写的简单记事本代码Dim b As String
Dim a As String
Dim m As String
Dim x As String
Private Declare Function SetWindowPos Lib "user32" ( _
ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal Y As Long, _
ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long _
) As Long
Const HWND_TOPMOST = -1
Const SWP_SHOWWINDOW = &H40
Private Sub baocun_Click()
Dim abc As String
If Len(Trim(m)) = 0 Then
m = "f:"
End If
abc = m &"\" &Text2.Text &".txt"
Open abc For Output As #1
Write #1, Text1.Text
Close #1
Label2.Caption = "保存的路径为:" &m &"\" &Text2.Text &".txt"
a = MsgBox("保存成功!" &Chr(13) &"是否退出程序", 4 + 64 + 0, "提示")
If a = vbYes Then
End
End If
End Sub
Private Sub Command1_Click()
Dir1.Visible = False
Drive1.Visible = False
m = Dir1.Path
Command1.Visible = False
b = MsgBox("你选的文件夹是:" &m, vbYesNo + vbDefaultButton1 + 48, "提示")
If b = vbNo Then
Dir1.Visible = True
Drive1.Visible = True
Command1.Visible = True
Else
Dir1.Visible = False
Drive1.Visible = False
Command1.Visible = False
End If
End Sub
Private Sub Command2_Click()
MsgBox (App.Path + "1.ico")
End Sub
Private Sub dakai_Click()
CommonDialog1.Filter = "文本文件(*.txt)|*.txt"
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Input As #1
Dim abc As String
linefromfile = StrConv(InputB(LOF(1), 1), vbUnicode)
Text1.Text = linefromfile
Close #1
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Form_Load()
Drive1.Drive = "f:\"
Dir1.Visible = False
Drive1.Visible = False
Command1.Visible = False
Dim fullpath As String
If Right(App.Path, 1) = "\" Then
fullpath = App.Path + "1.ico"
Else
fullpath = App.Path + "\" + "1.ico"
Form1.Icon = LoadPicture(fullpath)
End If
End Sub
Private Sub lingcunwei_Click()
Dim abc As String
CommonDialog1.ShowSave
If Len(Trim(CommonDialog1.FileName)) <>0 Then
x = CommonDialog1.FileName
Else
x = "f:\1.txt"
End If
Open x For Append As #1
Write #1, Text1.Text
Close #1
End Sub
Private Sub s_Click()
Text1.FontSize = 5
End Sub
Private Sub sanhao_Click()
Text1.FontSize = 12
End Sub
Private Sub st_Click()
CommonDialog1.ShowFont
End Sub
Private Sub shybcdwjj_Click()
Dir1.Visible = True
Drive1.Visible = True
Command1.Visible = True
End Sub
Private Sub Text2_GotFocus()
Dir1.Visible = False
Drive1.Visible = False
Command1.Visible = False
End Sub
Private Sub tuichu_Click()
End
End Sub
Private Sub wh_Click()
Text1.FontSize = 10
End Sub
Private Sub whs_Click()
Text1.FontSize = 10.5
End Sub
Private Sub xinjian_Click()
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub yh_Click()
Text1.FontSize = 24
End Sub
Private Sub zstj_Click()
MsgBox "所有字数为" &Len(Text1.Text), , " 字数"
End Sub
Private Sub ztys_Click()
CommonDialog1.ShowColor
Text1.ForeColor = CommonDialog1.Color
End Sub
Private Sub zzqm_Click()
Dim retValue As Long
'将窗体设置为处于所有窗口的顶层,注意在 VB 中运行时,可能不行,但编译成EXE后就可以了
retValue = SetWindowPos(Me.hwnd, HWND_TOPMOST, Me.CurrentX, Me.CurrentY, 380, 615, SWP_SHOWWINDOW)
End Sub
用VB做一个记事本实在不很复杂,我们完全可以通过向导来很方便地做出来。但本文只打算讨论用手动方法制作记事本,旨在向VB初学者展示:学VB原来是如此容易!通过阅读、研究本文并按本文所述进行尝试,初学者将学到很多东西,如怎样使用RichText控件来打开和保存文件,怎样制作菜单、工具栏和状态栏以及如何对其编写代码等。
第一章 让我们的记事本马上运行
急于求成是初学者共有的心愿。那好,请按如下三个步骤做,我们的愿望立即就可以实现!
步骤一:绘制界面。
新建一个标准EXE工程,将其Caption属性改为“超级记事本”,点击Icon属性给它找个合适的Icon图标。单击菜单“工程”-“部件”,在d出的“部件”对话框里找到Microsoft RichText Box 6.0和公共对话框Microsoft Common Dialog 6.0并选中它们,单击“确定”按钮。这时左边的工具栏上出现了我们刚才新添的两个控件了。在窗体上绘制RichText Box和Commn Dialog,其中RichText Box的大小和位置可不用理睬,我们将在代码中处理它,当然,有必要把它的ScrollBar属性设为2-rtfVertical,这样在打开和编辑文件时垂直滚动条才可用。
步骤二:编辑菜单。
按Ctrl+E调出菜单编辑器,我们来做如下几个菜单:
一.文件菜单:
文件(第一层) mnuFile
新建(第二层) mnuNew
打开(第二层) mnuOpen
保存(第二层) mnuSave
- (第二层) mnuFileSep (分隔线)
退出(第二层) mnuExit
二.编辑菜单:
编辑(第一层) mnuEdit
复制(第二层) mnuCopy
剪切(第二层) mnuCut
粘贴(第二层) mnuPaste
- (第二层) mnuEditSep (分隔线)
全选(第二层) mnuSelecAll
三.搜索菜单:
搜索(第一层) mnuSearch
查找(第二层) mnuFind
查找下一个(第二层) mnuFindOn
四.帮助菜单:
帮助(第一层) mnuHelp
使用说明(第二层) mnuUsage
关于(第二层) mnuAbout
(注:各菜单项的快捷键请自行设置)
好了,其它的菜单项以后再根据需要添加。现在进入:
步骤三:编写代码。
'声明查找变量
Dim sFind As String
'声明文件类型
Dim FileType, FiType As String
'初始化程序
Private Sub Form_Load()
'设置程序启动时的大小
Me.Height = 6000
Me.Width = 9000
End Sub
'设置编辑框的位置和大小
Private Sub Form_Resize()
On Error Resume Next '出错处理
RichTextBox1.Top=20
RichTextBox1.Left=20
RichTextBox1.Height = ScaleHeight-40
RichTextBox1.Width = ScaleWidth-40
End Sub
'新建文件
Private Sub mnuNew_Click()
RichTextBox1.Text = "" '清空文本框
FileName = "未命名"
Me.Caption = FileName
End Sub
'打开文件
Private Sub mnuOpen_Click()
CommonDialog1.Filter = "文本文档(*.txt)|*.txt|RTF文档(*.rtf)|*.rtf|所有文件(*.*)|*.*"
CommonDialog1.ShowOpen
RichTextBox1.Text = "" '清空文本框
FileName = CommonDialog1.FileName
RichTextBox1.LoadFile FileName
Me.Caption = "超级记事本:" &FileName
End Sub
'保存文件
Private Sub mnuSave_Click()
CommonDialog1.Filter = "文本文档(*.txt)|*.txt|RTF文档(*.rtf)|*.rtf|所有文件(*.*)|*.*"
CommonDialog1.ShowSave
FileType = CommonDialog1.FileTitle
FiType = LCase(Right(FileType, 3))
FileName = CommonDialog1.FileName
Select Case FiType
Case "txt"
RichTextBox1.SaveFile FileName, rtfText
Case "rtf"
RichTextBox1.SaveFile FileName, rtfRTF
Case "*.*"
RichTextBox1.SaveFile FileName
End Select
Me.Caption = "超级记事本:" &FileName
End Sub
'退出
Private Sub mnuExit_Click()
End
End Sub
'复制
Private Sub mnuCopy_Click()
Clipboard.Clear
Clipboard.SetText RichTextBox1.SelText
End Sub
'剪切
Private Sub mnuCut_Click()
Clipboard.Clear
Clipboard.SetText RichTextBox1.SelText
RichTextBox1.SelText = ""
End Sub
'全选
Private Sub mnuSelectAll_Click()
RichTextBox1.SelStart = 0
RichTextBox1.SelLength = Len(RichTextBox1.Text)
End Sub
'粘贴
Private Sub mnuPaste_Click()
RichTextBox1.SelText = Clipboard.GetText
End Sub
'查找
Private Sub mnuFind_Click()
sFind = InputBox("请输入要查找的字、词:", "查找内容", sFind)
RichTextBox1.Find sFind
End Sub
'继续查找
Private Sub mnuFindOn_Click()
RichTextBox1.SelStart = RichTextBox1.SelStart + RichTextBox1.SelLength + 1
RichTextBox1.Find sFind, , Len(RichTextBox1)
End Sub
'使用说明
Private Sub mnuReadme_Click()
On Error GoTo handler
RichTextBox1.LoadFile "Readme.txt", rtfText '请写好Readme.txt文件并存入程序所在文件夹中
Me.Caption = "超级记事本:" &"使用说明"
Exit Sub
handler:
MsgBox "使用说明文档可能已经被移除,请与作者联系。", vbOKOnly, " 错误信息"
End Sub
'关于
Private Sub mnuAbout_Click()
MsgBox "超级记事本 Ver1.0 版权所有(C) 2001 土人",vbOKOnly,"关于"
End Sub
'设置d出式菜单(即在编辑框中单击鼠标右键时d出的动态菜单)
Private Sub RichTextBox1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
PopupMenu mnuEdit, vbPopupMenuLeftAlign
Else
Exit Sub
End If
End Sub
'防止在切换输入法时字体自变(感谢王必成先生提供此方案)
Private Sub RichTextBox1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeySpace Then
RichTextBox1.SelFontName = CommonDialog1.FontName
End If
End Sub
至此,我们的记事本可以编译使用了。点击菜单“文件”-“生成XXX.EXE”,回到桌面运行我们的记事本看看,是不是颇有成就感?
当然,这样的记事本还比较粗糙,我们还需要做些工作,请看下一章。
第二章 美化程序界面
多数字处理软件都有工具栏和状态栏。工具栏和状态栏除了能美化我们的程序使其更具有专业性质外,还给用户带来 *** 作上的便利。现在我们就来做一做这两样东西。
一.工具栏
(一)制作工具栏
单击“工程”-“部件”,选中Microsoft Windows Common Control 6.0并确定。这时,我们要用到的控件就出现在左边的工具栏上了。
要做工具栏,首先需要一个叫ImageList的控件来装载图像。在程序界面上添加它,然后右键单击此控件,左键单击“属性”,d出“属性页”对话框的“图像”,再单击“插入图片”就可以一次性装载图片了(如不满意,以后还可以添加)。图片可在C:\Microsoft Visual Studio\Common\Graphics\Bitmaps\TlBr_W95下选择(这里假设你的VB安装在C盘下)。注意了:在插入图片时给每一张图片注明关键字,以便在引用图片时不至于混乱。如插入“新建”的图片,我们在“关键字”栏注明“New”。
图片有了,接下来在程序界面添加工具栏(ToolBar)。添加后工具栏就出现在菜单下面,右键单击它,选择“属性”,在d出的“属性页”对话框中的“通用”项作些设置,主要如下两项:
1.“图像列表”:选择ImageList1
2.“样式”:根据喜爱选择1-trbStandard或者2-trbFlat
继续点击“属性页”的“按钮”选项,插入若干按钮。按钮有多种样式,请根据需要设置。这里请一定注意:每一个与用户 *** 作有关的按钮都必须注明关键字、装载图片,如“新建”按钮,在“关键字”项注明“新建”,在“图像”项键入“New”(即ImageList1中的图片关键字),需要的话还可以在“工具提示文本”项填入适当的提示语。
(二)编写工具栏的按钮代码
工具栏按钮的代码编辑很简单,可以按照下面的格式去编写:
Private Sub ToolBar1_ButtonClick(ByVal Button As MSComctlLib.Button)
On Error Resume Next '出错处理
Select Case Button.Key '按关键字选择
Case "新建"
mnuNew_Click '等于菜单项“新建”被单击
Case "打开" '等于菜单项“打开”被单击
mnuOpen_Click
'......(继续编写其它按钮的代码)
End Select
End Sub
完成后试运行一下我们的程序,我们发现,有了工具栏之后,程序变得漂亮多了,只是有一个问题:打开一个较长的文档后,编辑框的下拉滚动条向上的箭头不见了。原因是:工具条占用一定的空间。解决方法:将“设置编辑框的位置和大小”中的RichTextBox1.Top = 20 和 RichTextBox1.Height = Me.ScaleHeight - 40分别改为RichTextBox1.Top = 380,RichTextBox1.Height = Me.ScaleHeight - 400即可。
二.状态栏
(一)制作状态栏
状态栏的英文名字叫StatusBar,在窗体上添加它后会默认出现在窗体的最下方。用鼠标右键点击它,调出“属性页”对话框,单击“窗格”项,插入一些窗格,可以将各个窗格的“样式”设置为:
0-sbrText 显示文本,需编写代码
1-sbrCaps 显示大小写状态,无需编程
2-sbrNum 显示NumLock键开关状态,无需编程
3-sbrIns 显示Insert键状态,无需编程
4-sbrScr1
5-sbrTime 显示时间,不编程时时间不会随系统时钟变化
6-sbrDate 显示日期,无需编程
注意:加进状态栏后需将Form_Resze中的RichTextBox1.Height = Me.ScaleHeight - 400改为RichTextBox1.Height = Me.ScaleHeight - 600。
(二)状态栏根据其“样式”属性决定用不用编写代码(如上文所述)。下面举些例子,读者可以认真揣摩,从而达到举一反三的效果。
例一:用户选取了“新建”后,让第一个窗格显示:“目前状态:正在打开文件《……》”。请将下面代码写进“打开”菜单里面:
StatusBar1.Panels(1).Text = "目前状态:正在打开文件" &"《" &CommonDialog1.FileTitle &"》"
例二:让第三个窗格显示时间并让时间跟随系统时钟变化。
首先,给程序加一个Timer控件,将其Interval属性设为1000。然后:
在Form_Load过程加入:StatusBar1.Panels(1).Text = Time;然后给Timer控件编写代码:
Private Sub Timer1_Timer()
If StatusBar1.Panels(3).Text <>CStr(Time) Then
StatusBar1.Panels(3).Text = Time
End If
End Sub
例三:当编辑框的文本发生变化时让第一个窗格显示:“正在编辑文档:文件名”。
Private Sub RichTextBox1_Chang()
StatusBar1.Panels(1).Text = "正在编辑文档:" &CommonDialog1.FileName
End Sub
辛苦了那么久,我们现在已经拥有一个象模象样的记事本了。这个记事本由于用了RichText控件,理论上它能打开和编辑任意大的文档,使用起来的确比Windows自带的记事本方便得多。当然,还有一些其它的功能需要添加和完善,这就靠你慢慢去完成了。
回答完毕!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)