vb编写文件管理器设计方案.docx
《vb编写文件管理器设计方案.docx》由会员分享,可在线阅读,更多相关《vb编写文件管理器设计方案.docx(20页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、vb编写文件管理器设计方案 VB语言编写文件资源管理器一、程序内部结构图 图1 图2 图3 图4 二、添加的对象名称 图5 图6 图7 图8 三、下方为本程序代码 Dim m As String, p As String, SourceFile As String, DestinationFile As String, w As Single, h As Single, a11 As Single, a12 As Single, a13 As Single, a14 As Single, b11 As Single, b12 As Single, b13 As Single, b14 As S
2、ingle, c11 As Single, c12 As Single, c13 As Single, c14 As Single, fname21 As String Private Sub chongmingming_Click() Dim newname As String, retempdir As String, lenfile As Integer, oldname As String e = InputBox(重命名, 输入新名字) If e = Then MsgBox 名称不为空 Exit Sub End If If File1.FileName = Then 文件夹重命名 I
3、f File1.Path Then 获得上级目录 retempdir = File1.Path lenfile = Len(retempdir) Do While Right$(retempdir, 1) If Right$(retempdir, 1) = : Then retempdir = retempdir & End If retempdir = Left$(retempdir, lenfile - 1) lenfile = Len(retempdir) Loop End If 获得上级目录 On Error GoTo hand oldname = File1.Path newname
4、 = retempdir & e Name oldname As newname If CurDir Then 返回上级目录 abc = CurDir lenfile = Len(abc) Do While lenfile 1 If Right$(abc, 1) = Then abc = Left$(abc, lenfile - 1) If Right$(abc, 1) = : Then abc = abc & End If Exit Do End If abc = Left$(abc, lenfile - 1) lenfile = Len(abc) Loop Dir1.Path = abc
5、ChDir Dir1.Path End If 返回上级目录 Exit Sub hand: MsgBox 文件不可重命名 文件夹重命名 End If If File1.FileName Then 文件重命名 If Right(File1.Path, 1) = Then fname21 = File1.Path & File1.FileName Else fname21 = File1.Path & & File1.FileName End If If fname21 Then 获得上级目录retempdir = fname21 lenfile = Len(retempdir) Do While
6、Right$(retempdir, 1) If Right$(retempdir, 1) = : Then retempdir = retempdir & End If retempdir = Left$(retempdir, lenfile - 1) lenfile = Len(retempdir) Loop End If 获得上级目录 oldname = fname21 newname = retempdir & e On Error GoTo hand1 Name oldname As newname If CurDir Then retempdir = CurDir lenfile =
7、 Len(retempdir) Do While lenfile 1 If Right$(retempdir, 1) = Then retempdir = Left$(retempdir, lenfile - 1) If Right$(retempdir, 1) = : Then retempdir = retempdir & End If Exit Do End If retempdir = Left$(retempdir, lenfile - 1) lenfile = Len(retempdir) Loop Dir1.Path = retempdir ChDir Dir1.Path End
8、 If Exit Sub hand1: MsgBox 文件重名不可重命名 End If End Sub 文件重命名 Private Sub Combo1_KeyPress(KeyAscii As Integer) On Error GoTo hand4 If KeyAscii = 13 Then File1.Pattern = Combo1.Text Combo1.SelStart = 0 Combo1.SelLength = Len(Combo1.Text) End If Exit Sub hand4: MsgBox 输入不合法 End Sub Private Sub Command1_Cl
9、ick() On Error GoTo hand File1.Pattern = Text1.Text Text1.SelStart = 0 Text1.SelLength = Len(Text1.Text) hand: MsgBox 输入不合法 End Sub Private Sub Dir1_Change() File1.Path = Dir1.Path File1.Path = Dir1.Path End Sub Private Sub Dir1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
10、If Button = 2 Then PopupMenu wenjian End If End Sub Private Sub Drive1_Change() Dir1.Path = Drive1.Drive Dir1.Path = Drive1.Drive End Sub Private Sub File1_DblClick() Dim retval Dim Fname As String On Error GoTo hand If Right(File1.Path, 1) = Then Fname = File1.Path & File1.FileName Else Fname = Fil
11、e1.Path & & File1.FileName End If retval = Shell(Fname, 1) 执行程序 Exit Sub hand: MsgBox 该文件非可执行文件 End Sub Private Sub File1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 2 Then PopupMenu bianji End If End Sub Private Sub Form_Load() Label2.Visible = False Text1.Vis
12、ible = False Command1.Visible = False Combo1.AddItem *.bmp Combo1.AddItem *.txt Combo1.AddItem *.doc Combo1.AddItem *.* w = Me.Width h = Me.Height a11 = File1.Height a12 = File1.Left a13 = File1.Width a14 = File1.Top b11 = Command1.Height b12 = Command1.Left b13 = Command1.Width b14 = Command1.Top c
13、11 = Text1.Height c12 = Text1.Left c13 = Text1.Width c14 = Text1.Top End Sub Private Sub guanbi_Click() End End Sub Private Sub Form_Resize() Dim j As Single Dim k As Single j = Me.Width / w k = Me.Height / h File1.Height = a11 * k File1.Left = a12 * j File1.Width = a13 * j File1.Top = a14 * k Dir1.
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- vb 编写 文件 管理器 设计方案
限制150内