易动轩

软件定制+网站开发、编程技术、杀毒软件、情感、社会

« 从10亿光年到0.1飞米VB表格控件总览与例程分析(转) »

VB6网页自动提交/自动填表的一种相对通用的方案

Private Sub Form_Load()
    WebBrowser1.Navigate sURL
End Sub

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    If URL = sURL Then
        Dim Ele As Object
          
        Set Ele = WebBrowser1.Document.getElementById("mobileno")           '根据ID取得对象
        Ele.Value = "www.m5home.com"
       
        Set Ele = WebBrowser1.Document.getElementsByName("password")        '根据Name取得对象
        Ele(0).Value = "www.m5home.com"
       
        Set Ele = WebBrowser1.Document.getElementsByName("operVerifyCode")  '根据Name取得对象
        Ele(0).Value = "www.m5home.com"
    End If
End Sub

在使用getElementsByName取对象时要注意一点,就是NAME是可以有重复的,所以getElementsByName返回的是一个集合,其中包含了所有相同NAME的对象.
而ID是不可能有重复的,所以getElementById返回的就是一个单一对象.

摘自www.m5home.com

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Spirit Build 80722 Code detection by Codefense

Copyright WWW.86LG.COM. All Rights Reserved.
浙ICP备09111194号