Results 1 to 1 of 1
  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006

    Post VB6 - SHDocVw.dll and WebBrowser control, different ways to load AJAX pages

    Today a lot of websites use AJAX to display content. Below are the 2 examples of how to load pages with AJAX, and how not to:

    1. Add reference to SHDocVw.dll, and a multiline Textbox to your form. This code will not load AJAX content.
    VB Code:
    1. Option Explicit
    2. Dim WithEvents myWeb As SHDocVw.InternetExplorer
    4. Private Sub Form_Load()
    5.     Set myWeb = New SHDocVw.InternetExplorer
    6.     myWeb.Navigate "http://video.yandex.ru/#search?text=test"
    7.     Do While myWeb.ReadyState <> READYSTATE_COMPLETE
    8.         DoEvents
    9.     Loop
    10.     Set myWeb = Nothing
    11. End Sub
    13. Private Sub myWeb_DownloadComplete()
    14. On Error Resume Next
    15. Text1.Text = myWeb.Document.body.innerHTML
    16. End Sub

    2. Add SHDocVw.dll as a component and place a WebBrowser control on your form; and add a multiline Textbox as well. This code does pretty much the same thing as the code above, except it will load AJAX content.
    VB Code:
    1. Option Explicit
    3. Private Sub Form_Load()
    4.     WebBrowser1.Navigate "http://video.yandex.ru/#search?text=test"
    5.     Do While WebBrowser1.ReadyState <> READYSTATE_COMPLETE
    6.         DoEvents
    7.     Loop
    8. End Sub
    10. Private Sub WebBrowser1_DownloadComplete()
    11. On Error Resume Next
    12. Text1.Text = WebBrowser1.Document.body.innerHTML
    13. End Sub

    Ref: http://en.wikipedia.org/wiki/Ajax_(programming)

    P.S. I used http://video.yandex.ru/#search?text=test only as an example, as most of the content on that page is loaded with AJAX. Feel free to test the code on any other page like Google or Yahoo.

    I'd love to see other examples of how to load AJAX-enabled pages. Please do post any suggestions.

    Last edited by foxter; May 18th, 2011 at 05:52 AM.

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

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.