【问题标题】:run time error "380' in Progress bar in VB 6.0VB 6.0 进度条中的运行时错误“380”
【发布时间】:2013-01-19 12:07:34
【问题描述】:

我在 VB 6.0 中制作了一个 Internet 浏览器,并为其提供了一个进度条... 输入链接并单击“开始”后。进度条的按钮值开始增加,但当它完全填满时,错误来了.. 运行时错误“380”: 无效的属性值。

Private Sub Command1_Click()
    WebBrowser1.Navigate Text1.Text
End Sub

Private Sub Command2_Click()
    WebBrowser1.GoBack
End Sub

Private Sub Command3_Click()
    WebBrowser1.GoForward
End Sub

Private Sub menuchangetheme_Click()
    CDB1.ShowColor
    Form1.BackColor = CDB1.Color
End Sub

Private Sub menuexit_Click()
    End
End Sub

Private Sub WebBrowser1_ProgressChange(ByVal Progress As Long, ByVal ProgressMax As Long)
    ProgressBar1.Value = 0
    If ProgressBar1.Value <> Val(ProgressBar1.Max) Then
        ProgressBar1.Value = ProgressBar1.Value + Val(Progress)
        ProgressBar1.Max = ProgressBar1.Value + 1
    Else
        ProgressBar1.Value = 0
    End If
End Sub

【问题讨论】:

  • 您似乎是在添加更新的进度值而不是替换它。进度值应该是一个百分比,所以只需在进度条上使用 0 到 100 并直接分配值。
  • 哦,千万不要使用End 语句。

标签: vb6


【解决方案1】:

ProgressProgressMax 参数已经是数字,因此您无需转换它们。正如 Deanna 指出的那样,您的代码正在将 Progress 添加到进度条的 Value 中。发生错误是因为您尝试分配一个大于进度条 Max 属性的值。

Private Sub WebBrowser1_ProgressChange(ByVal Progress As Long, ByVal ProgressMax As Long)

    On Local Error Resume Next 'suppress errors because they are not important enough to display to user

    If Progress > 0 Then                   'the page download is not complete
        ProgressBar1.Min = 0               'not really needed, but also doesn't hurt to set it here
        ProgressBar1.Max = ProgressMax + 1 'needs to be set because the ProgressMax can change every time the event is raised
        ProgressBar1.Value= Progress       'set the displayed value of the progressbar
    Else
        ProgressBar1.Value = 0             'the page load is finished
    End If

End Sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-18
    相关资源
    最近更新 更多