Error: HttpWebRequest on TextChanged Event [solved]
Need help with the following
its supposed to dl the source code of a site when a person types a web address into the textbox. The problem im having is when i start to type the address i get an error but if i copy and paste a link it dl the links source code. another problem is when the text box is cleared it throws another error
Code:
Imports System.Net
Imports System
Imports System.Text
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
F1 = Me
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text = " " Then
DialogResult = Windows.Forms.DialogResult.OK
Else
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(TextBox1.Text)
Dim response As HttpWebResponse = request.GetResponse
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream)
Dim code As String = sr.ReadToEnd
RichTextBox1.Text = code
End If
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
TextBox1.Clear()
End Sub
End Class