Hi All,

I know this is probably going to be very simple but looking for some help.

Currently i have a program that can put a website such as "www.google.co.uk" and pull all the HTML and put all that HTML inside a textbox unformatted.

Is there a way i can use an array maybe? or a storage container of some sort to KEEP that HTML inside that array or storage solution instead of just in a textbox?

Code is below!

Public Function GetPageHTML(ByVal URL As String, _
  Optional ByVal TimeoutSeconds As Integer = 60) _
  As String
    Dim objRequest As Net.WebRequest
    Dim objResponse As Net.WebResponse
    Dim objStreamReceive As System.IO.Stream
    Dim objEncoding As System.Text.Encoding
    Dim objStreamRead As System.IO.StreamReader

        objRequest = Net.WebRequest.Create(URL)
        objRequest.Timeout = TimeoutSeconds * 1000
        objResponse = objRequest.GetResponse
        objStreamReceive = objResponse.GetResponseStream
        objEncoding = System.Text.Encoding.GetEncoding( _
        objStreamRead = New System.IO.StreamReader( _
            objStreamReceive, objEncoding)
        GetPageHTML = objStreamRead.ReadToEnd()
        If Not objResponse Is Nothing Then
        End If
        Return ""
    End Try
End Function

Private Sub gobutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gobutton.Click
    imagestxt.Text = ""
    Dim strHTML As String
    strHTML = GetPageHTML(webaddresstxt.Text, 5)
    sourcecodetxt.Text = strHTML
End Sub

Move line 31 outside the function so that it becomes global then it can be used any time you want it.

I will admit that web stuff is not my strong point.

But would not the final document received by the webrowser control you are using hold the same HTML as your function retrieves?

You can receive a lot of documents before navigation is complete due to scripts executing on the page. This can be demonstrated with this small code sample.

Public Class Form1
   Private WithEvents wb As New WebBrowser
   Private tb As New TextBox With {.Multiline = True, _
                                   .Dock = DockStyle.Fill, _
                                   .ScrollBars = ScrollBars.Both, _
                                   .Font = New Font(Me.Font.FontFamily, 12, GraphicsUnit.Point)}

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      tb.Parent = Me
      wb.Url = New Uri("http:\\www.daniweb.com")
   End Sub

   Private doccount As Int32 = 0
   Private Sub wb_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles wb.DocumentCompleted
      doccount += 1

      tb.AppendText("Document:  " & doccount.ToString & " - " & e.Url.ToString & vbCrLf & vbCrLf)
      tb.AppendText(wb.DocumentText & vbCrLf)
      tb.AppendText(vbCrLf & New String("*"c, 60) & vbCrLf)
      If wb.Url = e.Url Then
         ' nav complete
         tb.AppendText(vbCrLf & " ********** Done!")
      End If
   End Sub
End Class