VB 中 文件复制 显示进度
我想用vb进行多个文件复制,并且显示进度,而且可以停止复制。就像安装软件时候那样。谢谢阁下能告诉我。...
我想用vb进行多个文件复制,并且显示进度,而且可以停止复制。
就像安装软件时候那样。
谢谢阁下能告诉我。 展开
就像安装软件时候那样。
谢谢阁下能告诉我。 展开
1个回答
展开全部
我以前下过一个VB例子,地址是
http://59.120.3.37/howto/300/data/progbar.zip
你可以参考一下
或者看代码
这儿有一段复制文件的代码(来源,以前的vbdak.net独龙),速度比Windows的复制文件要快一点,也不知道是为什么,可以利用一下
Label1显示进度百分比
Label2显示总计耗时
Label3显示总字节数
Label4显示已完成字节数
Option Explicit
Private exitcopy As Boolean
Private Sub Command1_Click()
Dim a() As Byte, s0 As Long, s1 As Long, buflen As Long, i As Long
Command1.Enabled = False
Command2.Enabled = True
i = Timer
buflen = 262143
Open "c:\2.mpg" For Binary As #1
Open "c:\1.mpg" For Binary As #2
s0 = LOF(1)
s1 = s0
Label3 = s0
If s1 > buflen Then ReDim a(buflen)
Do While s1 > buflen
Get #1, , a
Put #2, , a
s1 = Seek(1)
Label4 = s1
Label1 = "完成:" & FORMatPercent$(s1 / s0, 0, -1)
Label2 = Timer - i
DoEvents
If exitcopy Then GoTo last
s1 = s0 - s1
Loop
ReDim a(s1)
Get #1, , a
Put #2, , a
last:
s1 = s0
Label4 = s1
Label1 = "完成:" & FORMatPercent$(s1 / s0, 0)
Label2 = Timer - i
Close #1
Close #2
Command1.Enabled = True
Command2.Enabled = False
End Sub
Private Sub Command2_Click()
exitcopy = True
End Sub
http://59.120.3.37/howto/300/data/progbar.zip
你可以参考一下
或者看代码
这儿有一段复制文件的代码(来源,以前的vbdak.net独龙),速度比Windows的复制文件要快一点,也不知道是为什么,可以利用一下
Label1显示进度百分比
Label2显示总计耗时
Label3显示总字节数
Label4显示已完成字节数
Option Explicit
Private exitcopy As Boolean
Private Sub Command1_Click()
Dim a() As Byte, s0 As Long, s1 As Long, buflen As Long, i As Long
Command1.Enabled = False
Command2.Enabled = True
i = Timer
buflen = 262143
Open "c:\2.mpg" For Binary As #1
Open "c:\1.mpg" For Binary As #2
s0 = LOF(1)
s1 = s0
Label3 = s0
If s1 > buflen Then ReDim a(buflen)
Do While s1 > buflen
Get #1, , a
Put #2, , a
s1 = Seek(1)
Label4 = s1
Label1 = "完成:" & FORMatPercent$(s1 / s0, 0, -1)
Label2 = Timer - i
DoEvents
If exitcopy Then GoTo last
s1 = s0 - s1
Loop
ReDim a(s1)
Get #1, , a
Put #2, , a
last:
s1 = s0
Label4 = s1
Label1 = "完成:" & FORMatPercent$(s1 / s0, 0)
Label2 = Timer - i
Close #1
Close #2
Command1.Enabled = True
Command2.Enabled = False
End Sub
Private Sub Command2_Click()
exitcopy = True
End Sub
参考资料: http://59.120.3.37/howto/300/data/progbar.zip
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询