📄 frmfilefinder.frm
字号:
VERSION 5.00
Begin VB.Form frmMain
BorderStyle = 1 'Fixed Single
Caption = "简单的文件搜索器 - VB超市-韧恒软件工作室"
ClientHeight = 6240
ClientLeft = 45
ClientTop = 330
ClientWidth = 6225
Icon = "frmFileFinder.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 6240
ScaleWidth = 6225
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdExit
Caption = "结束搜索(&E)"
Height = 465
Left = 4567
TabIndex = 12
Top = 4320
Width = 1290
End
Begin VB.CommandButton cmdStop
Caption = "停止搜索(&S)"
Height = 465
Left = 1725
TabIndex = 11
Top = 4290
Width = 1290
End
Begin VB.CommandButton cmdFind
Caption = "立即搜索(&F)"
Height = 465
Left = 367
TabIndex = 10
Top = 4260
Width = 1290
End
Begin VB.ListBox lstFileList
Height = 3120
Left = 367
TabIndex = 9
Top = 1005
Width = 5490
End
Begin VB.TextBox txtPath
Height = 270
Left = 2212
TabIndex = 8
Top = 570
Width = 3645
End
Begin VB.TextBox txtFile
Height = 270
Left = 2212
TabIndex = 6
Top = 195
Width = 3645
End
Begin VB.Label labFileCount
Height = 180
Left = 1455
TabIndex = 15
Top = 5355
Width = 1260
End
Begin VB.Label Label6
Caption = "找到文件数:"
Height = 180
Left = 367
TabIndex = 14
Top = 5355
Width = 1170
End
Begin VB.Label labPath
Height = 180
Left = 1170
TabIndex = 13
Top = 5010
Width = 4785
End
Begin VB.Label Label2
Caption = "搜索范围(&L):"
Height = 180
Left = 367
TabIndex = 7
Top = 615
Width = 1080
End
Begin VB.Label Label1
Caption = "要搜索的文件名(&N):"
Height = 180
Left = 367
TabIndex = 5
Top = 240
Width = 1620
End
Begin VB.Label label5
Caption = "正在搜索: "
Height = 180
Left = 367
TabIndex = 4
Top = 5010
Width = 825
End
Begin VB.Line Line2
BorderColor = &H80000010&
X1 = 150
X2 = 6000
Y1 = 5625
Y2 = 5625
End
Begin VB.Line Line1
BorderColor = &H80000014&
BorderWidth = 2
X1 = 135
X2 = 6000
Y1 = 5640
Y2 = 5640
End
Begin VB.Label Label4
Caption = "主页:"
Height = 180
Left = 3240
TabIndex = 3
Top = 5850
Width = 450
End
Begin VB.Label Label3
Caption = "E-Mail:"
Height = 180
Left = 150
TabIndex = 2
Top = 5850
Width = 630
End
Begin VB.Label labSite
Caption = "http://vbsupermarket.yeah.net"
BeginProperty Font
Name = "Times New Roman"
Size = 9
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 225
Left = 3705
TabIndex = 1
Top = 5805
Width = 2355
End
Begin VB.Label labEmail
Caption = "renhengsoft@hotmail.com"
BeginProperty Font
Name = "Times New Roman"
Size = 9
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 225
Left = 825
TabIndex = 0
Top = 5805
Width = 2085
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'/************************************************************/
'/* == 程序简介 == */
'/* */
'/* 这个程序演示了如何在指定目录文件。与本站中另两个例子 */
'/* 不同的是,这个程序不仅支持通配符,而且速度更快,并在查找 */
'/* 过程中及时反馈给用户信息,因为它使用了类的方式。同样,结 */
'/* 合FindFileInSystem程序,你可以在整个机器的所有驱动器上查 */
'/* 找与指定模式相匹配的文件。如*.exe;*.txt;*.bmp等 */
'/* 具体情况请仔细阅读类模块,程序中有详细的说明及使用方 */
'/* 法。 */
'/* 你可以使用站内的查找功能找到下列相关代码: */
'/* 1. 在整个机器中查找文件的例子 */
'/* 2. 获得指定类型的驱动器的例子 */
'/* 3. 使用VB查找文件的例子, 这个例子也支持通配符 */
'/* */
'/* 2002.12.17 */
'/* */
'/* ======================================================== */
'/* ★ 本站声明 ★ */
'/* */
'/* 本站所写的代码中加上了大量的注释信息,由于每个程序员 */
'/* 对VB的设置不尽相同,如果代码(尤其是注释部分)的显示零乱无 */
'/* 顺,请在VB的选项中将代码字体设置为"Fixedsys"。 */
'/* */
'/* 作者不承诺该本例是解此类问题的唯一方案,只是为了演示 */
'/* 而作。 */
'/* */
'/* 如果您要转摘本代码,请保留原代码中的所有内容,包括注 */
'/* 释部分,以示对作者劳动的尊重,谢谢!如发现代码有问题,可 */
'/* 与作者联系。 */
'/* 本代码作者:VB超市站长-宋耀武 */
'/* http://vbsupermarket.yeah.net */
'/* E-Mail: renhengsoft@hotmail.com */
'/************************************************************/
'/*********************/
'/* 1. 常量声明部分 */
'/*********************/
'/*********************/
'/* 2. 类型声明部分 */
'/*********************/
'/*********************/
'/* 3. 变量声明部分 */
'/*********************/
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'%% 注意这个类的声明方式 %%
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Private WithEvents clsFindFile As Finder
Attribute clsFindFile.VB_VarHelpID = -1
'/*********************/
'/* 4. 函数声明部分 */
'/*********************/
'************************************************
' {找到一个新文件} - 加入列表,显示找到文件数
'************************************************
Private Sub clsFindFile_FindedFile(NewFilename As String)
lstFileList.AddItem NewFilename
labFileCount.Caption = clsFindFile.FileCount
End Sub
'**************************************
' {单击退出按钮} - 结束程序
'**************************************
Private Sub cmdExit_Click()
Unload Me
End Sub
'**************************************
' 开始查找文件
'**************************************
Private Sub cmdFind_Click()
lstFileList.Clear
clsFindFile.Filename = txtFile.Text
clsFindFile.FindPath = txtPath.Text
clsFindFile.StartFind
MsgBox Lenth
End Sub
'*******************************************
' {开始搜索下一个文件夹} - 显示文件夹名
'*******************************************
Private Sub clsFindFile_ChangPath(NewPath As String)
labPath.Caption = NewPath
End Sub
Private Sub cmdStop_Click()
clsFindFile.StopFind
End Sub
Private Sub Form_Load()
Set clsFindFile = New Finder
' FileCopy "E:\1.txt", "E:\...\1.text"
End Sub
'/**********************************************/
'/* 以下代码与本程序要说明的问题无关, 只用 */
'/* 于实现超链接效果。 */
'/**********************************************/
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, y As Single)
labEmail.FontUnderline = False
labEmail.ForeColor = &H800000
labSite.FontUnderline = False
labSite.ForeColor = &H800000
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set clsFindFile = Nothing
Set frmMain = Nothing
End Sub
Private Sub labEmail_Click()
ShellExecute hWnd, "open", "mailto: " & labEmail.Caption, "", App.Path, 1
End Sub
Private Sub labEmail_MouseMove(Button As Integer, Shift As Integer, X As Single, y As Single)
labEmail.FontUnderline = True
labEmail.ForeColor = vbBlue
End Sub
Private Sub labSite_Click()
ShellExecute hWnd, "open", labSite.Caption, "", App.Path, 1
End Sub
Private Sub labSite_MouseMove(Button As Integer, Shift As Integer, X As Single, y As Single)
labSite.FontUnderline = True
labSite.ForeColor = vbBlue
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -