Figured it out myself.
Imports System.IO
Imports System.Net
Imports System.Text
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents txtPageSource As System.Windows.Forms.TextBox
Friend WithEvents txtURL As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents btnGetSource As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.txtPageSource = New System.Windows.Forms.TextBox()
Me.btnGetSource = New System.Windows.Forms.Button()
Me.txtURL = New System.Windows.Forms.TextBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'txtPageSource
'
Me.txtPageSource.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.txtPageSource.Location = New System.Drawing.Point(8, 32)
Me.txtPageSource.Multiline = True
Me.txtPageSource.Name = "txtPageSource"
Me.txtPageSource.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.txtPageSource.Size = New System.Drawing.Size(672, 272)
Me.txtPageSource.TabIndex = 0
Me.txtPageSource.Text = ""
'
'btnGetSource
'
Me.btnGetSource.Anchor = (System.Windows.Forms.AnchorStyles.Bottom Or
System.Windows.Forms.AnchorStyles.Right)
Me.btnGetSource.Location = New System.Drawing.Point(552, 320)
Me.btnGetSource.Name = "btnGetSource"
Me.btnGetSource.Size = New System.Drawing.Size(112, 24)
Me.btnGetSource.TabIndex = 1
Me.btnGetSource.Text = "Get Source Code"
'
'txtURL
'
Me.txtURL.Anchor = ((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.txtURL.Location = New System.Drawing.Point(80, 8)
Me.txtURL.Name = "txtURL"
Me.txtURL.Size = New System.Drawing.Size(600, 20)
Me.txtURL.TabIndex = 2
Me.txtURL.Text = ""
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(8, 8)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(48, 23)
Me.Label1.TabIndex = 3
Me.Label1.Text = "URL"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(704, 366)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label1,
Me.txtURL, Me.btnGetSource, Me.txtPageSource})
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
txtURL.Text = "
http://www.jabtech.com"
End Sub
Private Sub btnGetSource_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnGetSource.Click
Dim inputURL, WebPageSourceCode As String
Dim WebPage As HttpWebRequest
Dim WebPageText As WebResponse
Dim WebPageSource As Stream
Dim WebPageSourceText As StreamReader
On Error GoTo ErrorHandler
txtPageSource.Text = ""
inputURL = txtURL.Text
WebPage = WebRequest.Create(inputURL)
WebPageText = WebPage.GetResponse()
WebPageSource = WebPageText.GetResponseStream
WebPageSourceText = New StreamReader(WebPageSource,
System.Text.Encoding.ASCII)
WebPageSourceCode = WebPageSourceText.ReadToEnd()
WebPageSourceText.Close()
WebPageSource.Close()
txtPageSource.Text = WebPageSourceCode
Exit Sub
ErrorHandler:
MsgBox("Invalid URL or page not available")
Exit Sub
End Sub
End Class