Newb AxWebBrowser question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tommydogs@gmail.com

    #1

    Newb AxWebBrowser question

    I am just starting out with AxWebBrowser and need help with a simple
    application. I just want to navigate to a web page, then read in
    source code. Here's what I have so far:

    Private Sub Form1_Load(ByVa l sender As System.Object, _
    ByVal e As System.EventArg s) Handles MyBase.Load

    AxWebBrowser1.N avigate("http://www.google.com" )

    End Sub

    Private Sub AxWebBrowser1_D ocumentComplete (ByVal sender As Object,
    ByVal e As AxSHDocVw.DWebB rowserEvents2_D ocumentComplete Event)

    ' what do I put here to grab the source code?

    End Sub



    Could someone please provide a snippet of code (along with any
    references I might need to add) that would load the page's source code
    into a string?

  • Oenone

    #2
    Re: Newb AxWebBrowser question

    tommydogs@gmail .com wrote:[color=blue]
    > Private Sub AxWebBrowser1_D ocumentComplete (ByVal sender As Object,
    > ByVal e As AxSHDocVw.DWebB rowserEvents2_D ocumentComplete Event)
    >
    > ' what do I put here to grab the source code?[/color]

    Dim src As String

    src = AxWebBrowser1.D ocument.Documen tElement.OuterH tml
    [color=blue]
    > End Sub[/color]

    HTH,

    --

    (O)enone


    Comment

    • tommydogs@gmail.com

      #3
      Re: Newb AxWebBrowser question

      Thank you for the quick response. I had tried something like that
      already, but using your code it looks like I am still getting a NULL
      return. For testing purposes, I am just trying to dump the results in
      a textbox on the page (TextBox1), but I am just seeing the auto-created
      "TextBox1" in TextBox1 when I use the following code:

      Private Sub AxWebBrowser1_D ocumentComplete (ByVal sender As Object,
      ByVal e As AxSHDocVw.DWebB rowserEvents2_D ocumentComplete Event)

      Dim src As String

      src = AxWebBrowser1.D ocument.Documen tElement.OuterH tml

      TextBox1.Text = src

      End Sub


      Am I making an obvious mistake?

      Comment

      • Oenone

        #4
        Re: Newb AxWebBrowser question

        tommydogs@gmail .com wrote:
        [color=blue]
        > Am I making an obvious mistake?[/color]

        I suspect your code isn't being called... Have you tried putting a
        breakpoint on the code within the event handler?

        The procedure declaration in the code that you quoted:

        \\\
        Private Sub AxWebBrowser1_D ocumentComplete (ByVal sender As Object,
        ByVal e As AxSHDocVw.DWebB rowserEvents2_D ocumentComplete Event)
        ///

        ....is incomplete. You have declared a Private Sub, but you haven't specified
        that it should handle the DocumentComplet e event of the browser control.

        Try adding the "Handles" clause, so that the procedure declaration looks
        like this:

        \\\
        Private Sub AxWebBrowser1_D ocumentComplete (ByVal sender As Object, _
        ByVal e As AxSHDocVw.DWebB rowserEvents2_D ocumentComplete Event) _
        Handles AxWebBrowser1.D ocumentComplete
        ///

        (Note the additional code in the third line). Then see if your code gets
        executed.

        HTH,

        --

        (O)enone


        Comment

        • tommydogs@gmail.com

          #5
          Re: Newb AxWebBrowser question

          Thanks, that was it!! I had that code (Handles) in the original
          version of my project, but somehwere in my frustrated monkeying around
          it got lopped off.

          Comment

          • Supra

            #6
            Re: Newb AxWebBrowser question

            thank

            Oenone wrote:
            [color=blue]
            >tommydogs@gmai l.com wrote:
            >
            >[color=green]
            >> Private Sub AxWebBrowser1_D ocumentComplete (ByVal sender As Object,
            >>ByVal e As AxSHDocVw.DWebB rowserEvents2_D ocumentComplete Event)
            >>
            >> ' what do I put here to grab the source code?
            >>
            >>[/color]
            >
            > Dim src As String
            >
            > src = AxWebBrowser1.D ocument.Documen tElement.OuterH tml
            >
            >
            >[color=green]
            >> End Sub
            >>
            >>[/color]
            >
            >HTH,
            >
            >
            >[/color]

            Comment

            • JasonChoi

              #7
              Re: Newb AxWebBrowser question

              I have a question about the event "DocumentComple teEvent" of AxWebBrowser.
              My code as follows, it will trigger two times(speaking "Loading completed"
              twice) when I submit a URL to handle. Why? Any suggestion?

              Private Sub WB_DocumentComp lete(ByVal sender As Object, ByVal e As
              AxSHDocVw.DWebB rowserEvents2_D ocumentComplete Event) Handles
              WB.DocumentComp lete
              tts.Speak("Load ing completed.") 'Text-to-Speech engine call
              End Sub



              "Oenone" wrote:
              [color=blue]
              > tommydogs@gmail .com wrote:
              >[color=green]
              > > Am I making an obvious mistake?[/color]
              >
              > I suspect your code isn't being called... Have you tried putting a
              > breakpoint on the code within the event handler?
              >
              > The procedure declaration in the code that you quoted:
              >
              > \\\
              > Private Sub AxWebBrowser1_D ocumentComplete (ByVal sender As Object,
              > ByVal e As AxSHDocVw.DWebB rowserEvents2_D ocumentComplete Event)
              > ///
              >
              > ....is incomplete. You have declared a Private Sub, but you haven't specified
              > that it should handle the DocumentComplet e event of the browser control.
              >
              > Try adding the "Handles" clause, so that the procedure declaration looks
              > like this:
              >
              > \\\
              > Private Sub AxWebBrowser1_D ocumentComplete (ByVal sender As Object, _
              > ByVal e As AxSHDocVw.DWebB rowserEvents2_D ocumentComplete Event) _
              > Handles AxWebBrowser1.D ocumentComplete
              > ///
              >
              > (Note the additional code in the third line). Then see if your code gets
              > executed.
              >
              > HTH,
              >
              > --
              >
              > (O)enone
              >
              >
              >[/color]

              Comment

              Working...