VB中一个关于drivelistbox ,dirlistbox, filelistbox的问题
如何用这三个控件制作一个程序,使两个文件夹(原文件夹,目标文件夹)里的文件相同,达到同步的目的。...
如何用这三个控件制作一个程序,使两个文件夹(原文件夹,目标文件夹)里的文件相同,达到同步的目的。
展开
展开全部
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
这个没错!
Dir1.Path = Drive1.Drive
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
这个没错!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
本人认为以上两位曲解了你的意思,你可以试试我的程序是否符合你的要求。
创建如下控件:
Drive1,Dir1,File1,Command1,Command2.
使用方法为:双击源文件夹,单击第一个按钮,双击目标文件夹,单击第二个按钮。同步完毕。
代码如下。
==============================
Dim p1 As String, p2 As String, r As Integer
Private Sub Command1_Click()
p1 = Dir1.Path
MsgBox "选定的同步源文件夹是:" & p1
End Sub
Private Sub Command2_Click()
p2 = Dir1.Path
r = MsgBox("选定的同步目标文件夹是:" & p2 & vbCrLf & "确定要同步吗?", vbOKCancel)
If r = vbOK Then
RmDir p2
MkDir p2
File1.Path = p1
Dim i As Integer
For i = 0 To File1.ListCount - 1
FileCopy p1 & "\" & File1.List(i), p2 & "\" & File1.List(i)
Next
ElseIf r = vbCancel Then
End If
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Form_Load()
Command1.Caption = "选定同步源文件夹"
Command2.Caption = "选定同步目标文件夹"
End Sub
创建如下控件:
Drive1,Dir1,File1,Command1,Command2.
使用方法为:双击源文件夹,单击第一个按钮,双击目标文件夹,单击第二个按钮。同步完毕。
代码如下。
==============================
Dim p1 As String, p2 As String, r As Integer
Private Sub Command1_Click()
p1 = Dir1.Path
MsgBox "选定的同步源文件夹是:" & p1
End Sub
Private Sub Command2_Click()
p2 = Dir1.Path
r = MsgBox("选定的同步目标文件夹是:" & p2 & vbCrLf & "确定要同步吗?", vbOKCancel)
If r = vbOK Then
RmDir p2
MkDir p2
File1.Path = p1
Dim i As Integer
For i = 0 To File1.ListCount - 1
FileCopy p1 & "\" & File1.List(i), p2 & "\" & File1.List(i)
Next
ElseIf r = vbCancel Then
End If
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Form_Load()
Command1.Caption = "选定同步源文件夹"
Command2.Caption = "选定同步目标文件夹"
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
private
sub
drive1_change()
dir1.path
=
drive1
end
sub
sub
drive1_change()
dir1.path
=
drive1
end
sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询