Results 1 to 8 of 8

Thread: [RESOLVED] Loop Through HTML Form Elements!

  1. #1

    Thread Starter
    Frenzied Member arpan_de's Avatar
    Join Date
    Oct 2005
    Location
    Mumbai, India
    Posts
    1,394

    Resolved [RESOLVED] Loop Through HTML Form Elements!

    I am using the WebBrowser control. I want to find out what are the different HTML Form elements existing in the web page a user is currently viewing. How do I do that?

    Thanks,

    Arpan

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Loop Through HTML Form Elements!

    Reference the MS HTML Object Library
    VB Code:
    1. Private Sub Form_Load()
    2. WebBrowser1.Navigate "http://www.vbforums.com/newthread.php?do=newthread&f=1"
    3.  
    4. End Sub
    5.  
    6. Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    7. If (pDisp Is WebBrowser1.Application) Then
    8.     On Error Resume Next
    9.     Dim wForm As HTMLFormElement
    10.     Dim wElem As HTMLInputElement
    11.     Set wForm = WebBrowser1.Document.Forms(1) 'Note the ONE (its actually the Second Form)
    12.     For x = 0 To wForm.elements.length
    13.         If TypeOf wForm.Item(x) Is HTMLInputElement Then
    14.             Set wElem = wForm.Item(x)
    15.             Debug.Print wElem.Name & ": " & wElem.Type
    16.         End If
    17.     Next
    18. End If
    19. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    Frenzied Member arpan_de's Avatar
    Join Date
    Oct 2005
    Location
    Mumbai, India
    Posts
    1,394

    Re: Loop Through HTML Form Elements!

    Thanks, Static, that's exactly what I was looking out for.

    BTW, to access all the hyperlinks existing in a web page, one can use wWeb.Document.All.tags("a") or to access the Forms, one can use wWeb.Document.All.tags("form").Name.

    I would like to know like ("a"), ("form"), what are the other tags?

    Arpan

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Loop Through HTML Form Elements!

    look in the html...
    <BODY> - body
    <A HREF> - a
    <FORM> - form
    <TABLE> - table
    etc...
    it should be any of those < > tags...
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5

    Thread Starter
    Frenzied Member arpan_de's Avatar
    Join Date
    Oct 2005
    Location
    Mumbai, India
    Posts
    1,394

    Re: Loop Through HTML Form Elements!

    Thanks Static.

    Arpan

  6. #6
    New Member
    Join Date
    Feb 2011
    Posts
    2

    Re: [RESOLVED] Loop Through HTML Form Elements!

    I'm trying the same thing, but using VS2010. I am getting an error after referencing MS HTML Object Library. The culpert seems to be

    WebBrowser1.Application

    is not a member of 'System.Windows.Forms.WebBrowser'

    What can I do to avoid this error?

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: [RESOLVED] Loop Through HTML Form Elements!

    Welcome to VBForums

    You are asking in completely the wrong place. While VB6 and VB.Net (VB 2002 and later) both have 'VB' in their names, they are very different languages.

    You should post a thread in our VB.Net forum instead.

  8. #8
    New Member
    Join Date
    Feb 2011
    Posts
    2

    Re: [RESOLVED] Loop Through HTML Form Elements!

    OK, thanks ... I will post in VB.NET forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width