程序在windows2000下正常 在windows2003下一运行就
提示 "   For i = 0 To vDoc.All.length - 1" 错误
load事件中没有WebBrowser1.Navigate "http://127.0.0.1/index.htm"Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    Dim vDoc, vTag
    Dim i As Integer
      
    Set vDoc = WebBrowser1.Document
    For i = 0 To vDoc.All.length - 1
        If UCase(vDoc.All(i).tagName) = "INPUT" Then
            Set vTag = vDoc.All(i)
            If vTag.Type = "text" Or vTag.Type = "password" Or vTag.Type = "hidden" Then
                Select Case vTag.Name
                    Case "Name"
                        vTag.Value = txtUserName.Text
                    Case "T"
                        vTag.Value = "Form Soft_IE"
                    Case "Password"
                        vTag.Value = txtPassword.Text
                End Select
 
        End If
    Next i
End Sub

解决方案 »

  1.   

    DocumentComplete在框架下载完成时也会被触发,这时候pDisp是框架,网页下载结束之后也会被触发,这时候pDisp是浏览器对象
    你可以通过判断pDisp是否是浏览器对象来判断页面是否下载完成
      

  2.   

    If UCase(vDoc.All(i).tagName) = "INPUT" Then
                Set vTag = vDoc.All(i)
                If vTag
    .....
    End if
    老兄,你少了一个End if 怎么可能运行正常
      

  3.   

    我在win2003En添加了一个End if 以后没有发现报错