1

我已经在 VB 6.0 中制作了一个 Internet 浏览器,并且我已经给它一个进度条......当输入链接并单击“GO”后。进度条的按钮值开始增加,但当它完全填满时,错误来了。运行时错误“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
4

1 回答 1

0

参数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
于 2013-01-19T04:07:34.223 回答