How do i add remove Web browser control from a module

Posted on 2011-03-25
Last Modified: 2012-05-11
I order to get page data from web site i'm using this code: (get page)
this code after a few pages donut work i think maybe because i'm  not add/remove web bowser properly from my form: "frmMain".
can some one fix it?

sample URL:

Public Function Get_Page(ByVal sURL As String) As String

        Dim sResult As String = vbNullString
            Const cTitle As String = "144 ¿¿¿"
            Dim oWeb As New WebBrowser
            With oWeb
                oWeb.Name = "WebBrowser1"
                .Visible = True
                sResult = .DocumentTitle
                Dim iCount As Integer = 0
                Do Until InStr(sResult, cTitle) > 0
                    iCount = iCount + 1
                    sResult = .DocumentTitle
                    If iCount >= 3 Then
                        If len(sResult)=0 Then
                            Exit Try
                        end if
                    End If
                Dim sr As System.IO.StreamReader = New           System.IO.StreamReader(.DocumentStream, System.Text.Encoding.UTF8)
                sResult = sr.ReadToEnd()
            End With
        Catch ex As Exception
            'MsgBox(Err.Description & Chr(32) & Err.Number & vbCrLf & "Proc getrequestuelsource mod app actions")
        End Try
        Return sResult
        'sr = new System.IO.StreamReader(objRes.GetResponseStream(), System.Text.Encoding.GetEncoding("windows-1255"));

    End Function

Open in new window

Question by:rshaham
1 Comment
LVL 32

Accepted Solution

Erick37 earned 500 total points
ID: 35220392
Perhaps it would work better if you added the webbrowser control to the form design time rather than runtime?

Another thought: you are trying to dispose the control prior to removing it from the control collection.  It may work better to remove it, then dispose...


Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SHA256 Code Signing 4 168
Run a query from result of another query - 2 58
ASP.NET Installation in Windows Server 2012 5 96
Dotnet libraries on server 11 60
In Easy String Encryption Using CryptoAPI in C++ ( I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question