webbrowser control in a module

P

pmclinn

I have some webbrowser code using the .net 2.0 control on a form. I
want to remove the form and run the proceedure from a module but I
cannot seem to get the code to work.

Code in form that works:
WebBrowser1.Navigate("http://website")

in the completed event handler I have this
Static quit As Integer = 0
If quit = 0 Then
Dim l As HtmlElement
l = WebBrowser1.Document.All("txtTo")
l.InnerText = "(e-mail address removed)"
l = WebBrowser1.Document.All("txtFrom")
l.InnerText = "(e-mail address removed)"
l = WebBrowser1.Document.All("txtSubject")
l.InnerText = "Testing Document"
l = WebBrowser1.Document.All("txtBody")
l.InnerText = ("Testing Body")
l = WebBrowser1.Document.All("btnSubmit")
l.InvokeMember("Click")

quit += 1
End If
WebBrowser1.Dispose()

This code works in the form but when I move it into a sub main
proceedure it doesn't work. How do I make this work? I created a
public variable:

Public webb withevents as webbrowser

and added in the completed event but the code is not running. Help.
 
H

Herfried K. Wagner [MVP]

pmclinn said:
I have some webbrowser code using the .net 2.0 control on a form. I
want to remove the form and run the proceedure from a module but I
cannot seem to get the code to work.

Code in form that works:
WebBrowser1.Navigate("http://website")

I assume the actual window handle of the webbrowser control cannot be
created if it doesn't get added to a form's or control's 'Controls'
collection.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top