Martin2k Forums

Board index Visual Basic Visual Basic Tutorials, Tricks & Tips

Something To Share: Get Source Code With Inet Control

This is where you can post your VB & VB.Net Tutorials, Tricks & Tips.

Something To Share: Get Source Code With Inet Control

Postby CDRIVE » Mon Mar 22, 2010 6:12 pm

Not having played with Internet controls to any great extent, I've spent the last week searching for information regarding the WebBrowser and Inet controls. My project required getting the source code of a webpage, so when I couldn't find a method using the WebBrowser control I included the Inet control in my search. Anyway, I found this code at CodeItBetter.
CodeItBetterGetSourceCode
When that code failed to work for me I read up on the Inet control in the Object Browser. After very little reading I modified the CodeItBetter sample with the code below. I was pleasantly surprised to see the RTB fill with source code. B)
Code: Select all
Option Explicit

Private Sub Form_Load()
   Dim strSrc As String
'   Inet1.URL = "http:/www.nothing"    ' MsgBox bad URL test string
   Inet1.URL = "http://www.martin2k.co.uk/"
   strSrc = Inet1.OpenURL(Inet1.URL)
   If Len(strSrc) > 0 Then
      RichTextBox1 = strSrc
   Else
      MsgBox "Source code is not available.", vbInformation, "Page Error"
   End If
End Sub
You don't need to know everything, you just need to know how to find the information.
On the other hand, having knowledgeable friends can't hurt!
User avatar
CDRIVE
Level 1
 
Posts: 140
Joined: Sun Jan 10, 2010 9:21 pm
Location: Delray Beach, Florida. USA

Re: Something To Share: Get Source Code With Inet Control

Postby Keith » Mon Mar 22, 2010 11:27 pm

Ok Chris so that code is working as you want it too now?

Do you have another problem with this project or are you just passing on that useful link?

If you're just passing the link on then I will move this topic to the VB Tutorials if you want too? ;)
I've been programming with VB for 17 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

Image
Keith
Administrator
 
Posts: 869
Joined: Tue Oct 13, 2009 12:15 am
Location: Stoke on Trent, England
Medals: 1
6 Star (1)

Re: Something To Share: Get Source Code With Inet Control

Postby CDRIVE » Tue Mar 23, 2010 1:37 am

Yes Keith, I was just passing along some useful information. If you would like to put this in the code bank please do. By the way, I also managed to pull the HTML source code using the WebBrowser control. When I get the code cleaned up I'll post that too. :)
You don't need to know everything, you just need to know how to find the information.
On the other hand, having knowledgeable friends can't hurt!
User avatar
CDRIVE
Level 1
 
Posts: 140
Joined: Sun Jan 10, 2010 9:21 pm
Location: Delray Beach, Florida. USA

Re: Something To Share: Get Source Code With Inet Control

Postby Keith » Tue Mar 23, 2010 4:06 pm

Ok I've moved it for you Chris. If you find any more additional info on this the just add it. If its a new tip or trick then just make a new topic in here. We are running short of this type of help. ;)
I've been programming with VB for 17 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

Image
Keith
Administrator
 
Posts: 869
Joined: Tue Oct 13, 2009 12:15 am
Location: Stoke on Trent, England
Medals: 1
6 Star (1)

Re: Something To Share: Get Source Code With Inet Control

Postby CDRIVE » Tue Mar 23, 2010 9:55 pm

Keith, thanks for moving it. When I get some time I'll add to the Tips & Tricks section. B)
You don't need to know everything, you just need to know how to find the information.
On the other hand, having knowledgeable friends can't hurt!
User avatar
CDRIVE
Level 1
 
Posts: 140
Joined: Sun Jan 10, 2010 9:21 pm
Location: Delray Beach, Florida. USA


Return to Visual Basic Tutorials, Tricks & Tips

Who is online

Users browsing this forum: No registered users and 1 guest

cron