CodeItBetter Programming Another VB Programming Blog

How to Retreive the Source code of a web page

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
'Internet - How to Retreive the Source code of a web page
Option Explicit
 
'Place the following controls on a form: RichTextBox1 (Rich Textbox);
'Inet1 (Internet Control); Text1 (Textbox); Command1 (Command button)

Private Sub Command1()
    Dim Source1 As String
    If Len(Text1) > 0 Then  ' We'll assume the User entered a URL for Download
        Source1 = Inet1.OpenURL(Me.Text1.Text)
        If Len(Source1) > 0 Then
            RichTextBox1.Text = Source1
            Me.Inet1.Cancel
        Else
            Source = MsgBox("Source code is not available.", vbInformation, "Source Code")
        End If
    End If
End Sub
Filed under: Internet Leave a comment
Comments (1) Trackbacks (0)
  1. I could not get this code to work as posted. Maybe I was doing something wrong. I re-wrote the code as listed below, which did work for me.

    Option Explicit

    Private Sub Form_Load()
    Dim mySource As String
    Inet1.URL = “http://www.SomeUrl”
    mySource = Inet1.OpenURL(Inet1.URL)
    RichTextBox1 = mySource
    End Sub


Leave a comment


 

No trackbacks yet.