Newbie question: displaying HTML source code

P

peter

I am very new with VB and it has a much different syntax than the
other languages that I program in
(C/C++/Java/JavaScript/ActionScript/PHP/Perl). I have three elements
in my very simple program: rich text box (named source), an activex
component "Windows Web Browser" (named webView), and two timers (named
Timer1 and Timer2). The first timer successfully loads the web page
into webView and unenables it's self. The second timer waits a couple
seconds then it is SUPPOSSED TO display the source code contents in
the rich text box.

My code for the second timer (Timer2) is:
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer2.Tick
source.Text = webView.Text
'source.Text = "Test this"
Timer2.Enabled = False
End Sub

The commented out test works fine in the rich text box, but
source.Text = webView.Text doesn't do anything. Is there a way to view
source from the "Windows Web Browser"?

P.S. I got this to work with the Beta version of Studio 2005, but it
won't let me compile the app to a stand alone state that can be used
on computers that don't have Studio 2005 installed. I am using Studio
2003 with the .NET framework 1.1 sp1 installed.

Any ideas on how to get this to work would help me out a bunch.
 
L

Larry Serflaten

peter said:
I have three elements
in my very simple program: rich text box (named source), an activex
component "Windows Web Browser" (named webView), and two timers (named
Timer1 and Timer2). The first timer successfully loads the web page
into webView and unenables it's self. The second timer waits a couple
seconds then it is SUPPOSSED TO display the source code contents in
the rich text box.

2 comments.

1. If you have to finish a report by 3:00 and are expecting a call at 4:00,
you are not likely to use two different clocks to wtach for those events.
Likewise you don't really need 2 timers, only a means to decide what
must be done when the timer event fires.

2. Using VS 2003, I don't see a 'Windows Web Browser' control, I do
see a 'Microsoft Web Browser' and can only assume they are the same.

In your tick event, if you haven't called on the page, do that, but if you've
done that, let the timer continue ticking and watch for the WB's Document
property to be filled:

If Not webView.Document Is Nothing Then
source.Text = webView.Document.documentElement.innerHTML
MyTimer.Enabled = False
End If


When the document is ready, then get the document's HTML and shut off
the timer.

That should get you going, however, it is probably more correct to
use the browser's DocumentComplete event. But, since you are not
in a tight loop testing for that document object, that may just work
well for your needs....

LFS
 
C

Cor Ligthert

Peter,

In addition to Larry,

Keep in mind that VBNet is different from VB, C# and VBNet have very much
more in common than VB and VBNet.

The main differences between C# and VBNet are in my opinion.

The way of declaring which you find back in every part of the languages
Dim A as String (in VBNet)
String A; (in C derived languages)

The use of the operators where in my opinion in VBNet are the booleans
strange and in C# the strange equal comparer derived from C.

With that you have in my opinion had the major differences.

Another difference however no language itself, is that the VBNet IDE is (in
my opinion again) very superior to the C# IDE. The VBNet IDE automaticly
corrects and add on a lot of places the spelling of the syntax before
compile time (It has a backgroundcompiler working all the time).
-------------------------------
Than the webbrowser as Larry told.

Net 2.0 has as new part an integrated webbrowser, in previous versions is
used interop to reusing the webbrowser what is of course completly
different.

I hope this gives some idea's?

Cor
 
C

Cor Ligthert

Tim,

Thanks for the information,

I have searched a while ago for some information about it, then the
information was very weak (I only found something that it was said), do you
have a direct Microsoft link for me about it?

Cor

"Tim Anderson"
 
T

Tim Anderson

Cor Ligthert said:
Tim,

Thanks for the information,

I have searched a while ago for some information about it, then the
information was very weak (I only found something that it was said), do
you have a direct Microsoft link for me about it?

http://www.windowsforms.net/WhidbeyFeatures/default.aspx?PageID=2&ItemID=18&Cat=Controls&tabindex=5

Not very detailed though. Best to install the Community Preview and have a
look :)

Tim
..NET pros and cons
http://www.itwriting.com/phorum/list.php?f=6
 
C

Cor Ligthert

Tim,

More than enough for me, it exactly tells what you say and the extra on the
page tells that the benefit seems that you can avoid in future mshtml.

The last is really a big benefit in my opinion, because the axbrowser is not
bad, however working with MSHTML with early binding needs sometimes 2 times
casting and than only when you have first created a subcollection using
casting.

When than the exec method as well can be more avoided what I expect from the
text, than it will be even more greath.

This is all I needed to know for now.

Thanks again

Cor
 

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