Error: HttpWebRequest on TextChanged Event [solved]

Posts 1–11 of 11 · Page 1 of 1
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
Don't use the textchanged event lol.
well i fixed the if the text box is clear with

Code:
If String.IsNullOrEmpty(uri) Then
            DialogResult = Windows.Forms.DialogResult.OK

Code:
[Dim uri As String = TextBox1.Text
        If String.IsNullOrEmpty(uri) Then
            DialogResult = Windows.Forms.DialogResult.OK
        Else
            Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(uri)
            Dim response As HttpWebResponse = request.GetResponse
            Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream)
            Dim code As String = sr.ReadToEnd
            sourceview.Text = code


        End If
    End Sub
i just wanted to use tetxbox.text change cause it was a little faster and less buttons ...but i guess ill stick to what i have
yeah that worked thanks for the simple code =p
Shouldn't this be enough:

[highlight="VB.Net"]WithEvents wc as new Net.Webclient[/highlight]

[highlight="VB.Net"]If Not Textbox1.text = string.empty Then Richtextbox1.text = wc.downloadstring(textbox1.text)[/highlight]
Marked solved. Good job Kevin.
Quote Originally Posted by Jason View Post
Marked solved. Good job Kevin.
It doesn't look solved from here
But that might just be me.
Quote Originally Posted by Nathan View Post


It doesn't look solved from here
But that might just be me.
It's just you.
Quote Originally Posted by Nathan View Post


It doesn't look solved from here
But that might just be me.
Quote Originally Posted by EPT+
yeah that worked thanks for the simple code =p
You retarded or some shit?
Quote Originally Posted by Jason View Post




You retarded or some shit?
Me or the other guy you quoted?
Quote Originally Posted by Nathan View Post


Me or the other guy you quoted?
You, obviously. The OP said the thread was solved
Posts 1–11 of 11 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us