是的,所以我有2个进度条,我在计算理论上第二个进度条(整体进度)的进度时所做的等式应该可以正常工作。它适用于第一次下载,但是当它进入第二次下载而不是继续它直接跳到100。
现在我不确定这是因为我的自定义进度条还是因为其他原因。
这是我的进度条代码。
If CProgressBarCurrent.Value >= 1 Then
CProgressBarTotal.Value = (100 * (currentFileNumber - 1) + CProgressBarCurrent.Value) / Me.fileUrls.Count
End If
这些是功能:
Dim currentFileNumber As Integer = 1
每次下载完成后我都会添加一个。
CProgressBarCurrent.Value
我的第一个进度条的值,显示已下载的文件数量。明智的。
Me.fileUrls.Count
队列中的文件数量。
我还尝试了另一个方程式:
CProgressBarTotal.Value = (currentFileNumber / Me.fileUrls.Count + CProgressBarCurrent.Value / 100 / Me.fileUrls.Count) * 100
这部分也有效,但它有同样的问题。当第一次下载完成而不是继续时,它只会达到100%。
我通过计时器滴答来管理这个。因此,对于每个刻度,它都会执行该过程。
这是我的进度条最大值属性:
Property Maximum As Double
Get
Return MaxValue
End Get
Set(ByVal value As Double)
If MaxValue < 0 Then MaxValue = 0 Else If MaxValue < MinValue Then MaxValue = MinValue
MaxValue = value
End Set
End Property
这是我的Value属性:
Property Value As Double
Get
Return Percent
End Get
Set(ByVal value As Double)
If value < Minimum Then value = Minimum Else If value > Maximum Then value = Maximum
Percent = value
If Percent = 0 Then
PictureBox1.Width = CInt(value * 3.74)
Else
PictureBox1.Width = CInt(value * 3.74 / Maximum * 100)
End If
End Set
End Property
我的声明:
Protected MinValue As Double = 0.0
Protected MaxValue As Double = 100.0
Protected Percent As Double = 0.0
感谢。
答案 0 :(得分:0)
正确的等式如下:
CProgressBarTotal.Value = ((currentFileNumber - 1) + CProgressBarCurrent.Value / 100 ) * 100 / Me.fileUrls.Count
这来自两个部分:
percentOfCompletedFiles = (currentFileNumber - 1) / Me.fileUrls.Count * 100
percentCurrentFileReferredAllFiles = CProgressBarCurrent.Value / Me.fileUrls.Count
添加并简化整体。
为了实现这一目标,必须满足一些条件:
答案 1 :(得分:0)
如果您只是将第二个进度条的最大值设置为File.Urls.Count并为每个已完成的文件添加1,它应该可以正常工作。