Personal computing discussed

Moderators: renee, SecretSquirrel, just brew it!

 
random gerbil
Gerbil Jedi
Topic Author
Posts: 1694
Joined: Fri Feb 06, 2004 4:12 pm
Location: Brooklyn
Contact:

Visual Basic and Web Pages

Thu Mar 17, 2005 5:11 pm

I have a simple project which uses the WebBrowser control to display web pages within the project. How would i go about having the project output the html source of the page to a text file (as opposed to me right clicking and selecting "View Source")? Any ideas?
Does anyone remember laughter?
 
UberGerbil
Grand Admiral Gerbil
Posts: 10368
Joined: Thu Jun 19, 2003 3:11 pm

Thu Mar 17, 2005 7:04 pm

I'm assuming you mean "classic" VB and not VB.NET?

The simplest way is to use the Internet Transfer control. You can do it directly from the webbrowser control too, IIRC. To do that, add a reference to the "Microsoft HTML Object Library" (mshtml.tlb) -- this isn't strictly necessary but it will give you intellisense and compile-time error checking. And write code like this (note: not tested; I don't have VB6 handy anymore)
Dim doc As MSHTML.HTMLDocument ' or As Object if no ref to HTML Object Library
    Set doc = WebBrowser1.Document
    Dim f As Integer
    f = FreeFile
    TextBox1.Text = doc.documentElement.innerHTML 'if you want to display it
    Open "c:\source.html" For Output As #f
    Print #f, doc.documentElement.innerHTML
    Close #f
There's more about the webbrowser control; you might find this article useful as well.
 
random gerbil
Gerbil Jedi
Topic Author
Posts: 1694
Joined: Fri Feb 06, 2004 4:12 pm
Location: Brooklyn
Contact:

Fri Mar 18, 2005 2:29 pm

Thanks much for the information. Did a lot of searchin yesterday but couldnt find anything that addressed whether or not i could do it.
Does anyone remember laughter?

Who is online

Users browsing this forum: No registered users and 1 guest
GZIP: On