| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 315 人关注过本帖
标题:急!这个代码错在哪?
只看楼主 加入收藏
miminone
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2012-5-4
结帖率:0
收藏
 问题点数:0 回复次数:1 
急!这个代码错在哪?
错误91,对象变量或with块变量未设置。是个填表自动化的问题。流程:1.第一个页面,只有submit进入下一页按钮,点击;2、进入第二个页面,填表,有q1和q2两项, 填表完毕后点击submit提交。

Private Sub WebBrowser6_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim tg5
Dim d5
Dim doc5 As String
Dim doctext
Dim i As Long

Set doctext = WebBrowser6.Document.body.createTextRange()
Set d5 = WebBrowser6.Document
doc5 = doctext.htmltext

For i = 0 To d5.All.length - 1
 Set tg5 = d5.All(i)
    If LCase(d5.All(i).tagName) = "input" Or LCase(d5.All(i).tagName) = "select" Then
        If InStr(1, doc5, "开始") > 0 Then
              If tg5.Type = "submit" Then
              tg5.Click
               End If
        End If
        If InStr(1, doc5, "signup/cc/page1") > 0 Then
             If tg5.Type = "radio" Then
                Select Case tg5.Name
                 Case "q1"
                 tg5.Value = "7"
                 Case "q2"
                 tg5.Value = "2"
                End Select
             ElseIf tg5.Type = "submit" Then
                 tg5.Click
            End If
        End If
    End If
Next i
End Sub
搜索更多相关主题的帖子: Object 
2012-05-05 11:40
miminone
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2012-5-4
收藏
得分:0 
上面的代码问题我知道错在哪了,现在是以下这个关键问题:
Private Sub Command1_Click()
WebBrowser6.Navigate "

Private Sub Command2_Click()
Dim tg5
Dim d5
Dim doc5 As String
Dim doctext
Dim i As Long


Set doctext = WebBrowser1.Document.body.createTextRange()
Set d5 = WebBrowser1.Document
doc5 = doctext.htmltext

For i = 0 To d5.All.length - 1
Set tg5 = d5.All(i)
    If LCase(d5.All(i).tagName) = "input" Or LCase(d5.All(i).tagName) = "select" Then
        If InStr(1, doc5, "开始") > 0 Then
              If tg5.Type = "submit" Then
              tg5.Click
               End If   
        End If
        If InStr(1, doc5, "signup/page1") > 0 Then
             If tg5.Type = "radio" Then
                Select Case tg5.Name
                 Case "q1"
                 tg5.Value = "7"
                 Case "q2"
                 tg5.Value = "2"
                End Select
             ElseIf tg5.Type = "submit" Then
                 tg5.Click
            End If
        End If
    End If
Next i
End Sub
点击了第1页 的注册按钮后,第二页的填表和按钮就完全不执行了,我觉得If InStr(1, doc5, "开始") > 0 Then 和If InStr(1, doc5, "signup/page1") > 0 Then在这里没有起作用,请问如何修改?


2012-05-05 13:04
快速回复:急!这个代码错在哪?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018246 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved