Results 1 to 22 of 22

Thread: Inet control..

  1. #1

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Inet control..

    I cant seem to find it, what is its name in .net?

  2. #2
    Addicted Member
    Join Date
    Jun 2005
    Posts
    175

    Re: Inet control..

    By Inet control, are you referring to Internet Explorer? How do you want to control it? Are you trying to have a browser window within a form? Or execute and control a seperate instance of IE?

  3. #3

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Inet control..

    Well, in vb6 theres a control that lets me access a webpage thru vb totally in text. It will take the source of a page and give it directly to you. It doesnt seem like theres a control to do this anymore? How would i get the text off a website into a textbox without running a webbrowser control ?

  4. #4
    Fanatic Member -TPM-'s Avatar
    Join Date
    Jul 2005
    Posts
    850

    Re: Inet control..

    Take a look at the system.net namespace, there's webclient/request. You can probably do it with those, I've never done it though so I don't have any code for you...
    TPM

    Add yourself to the VBForums Frappr Map!!

  5. #5

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Inet control..

    well...i added the namespace but i dont know what to do now..Nothing new is on the left hand bar of my screen. Im not sure what to do now

  6. #6
    Fanatic Member -TPM-'s Avatar
    Join Date
    Jul 2005
    Posts
    850

    Re: Inet control..

    It won't give you a GUI control, you'll need to call it in code.
    TPM

    Add yourself to the VBForums Frappr Map!!

  7. #7

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Inet control..

    Okay, gotcha now...Just i dont know which option to use

  8. #8
    Fanatic Member -TPM-'s Avatar
    Join Date
    Jul 2005
    Posts
    850

    Re: Inet control..

    Well you could use webclient to download the file and read it...
    What exactly do you want to download?
    TPM

    Add yourself to the VBForums Frappr Map!!

  9. #9
    Addicted Member
    Join Date
    Jun 2005
    Posts
    175

    Re: Inet control..

    Okay, here's a quickie. This is based on a form with two textboxes, and an execute button. Textbox1 is for the url. Textbox2 is the souce of the page. Button1 gets the source and displays it in textbox2.

    Before you do this, you need to set Options Explicit On, and add the following imports to your namespace:

    Imports System.IO
    Imports System.Net
    Imports System.Text

    Add the following to the button executing the code:

    Code:
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim uri As New Uri(TextBox1.Text)
            Dim builder As New StringBuilder
            builder.Append("AbsolutePath: " & uri.AbsolutePath & ControlChars.CrLf)
            builder.Append("AbsoluteUri: " & uri.AbsoluteUri & ControlChars.CrLf)
            builder.Append("Host: " & uri.Host & ControlChars.CrLf)
            builder.Append("HostNameType: " & uri.HostNameType.ToString() & _
                            ControlChars.CrLf)
            builder.Append("LocalPath: " & uri.LocalPath & ControlChars.CrLf)
            builder.Append("PathAndQuery: " & uri.PathAndQuery & ControlChars.CrLf)
            builder.Append("Port: " & uri.Port & ControlChars.CrLf)
            builder.Append("Query: " & uri.Query & ControlChars.CrLf)
            builder.Append("Scheme: " & uri.Scheme)
            Dim request As WebRequest = WebRequest.Create(uri)
            Dim response As WebResponse = request.GetResponse()
            builder = New StringBuilder
            builder.Append("Request type: " & request.GetType().ToString() & _
                    ControlChars.CrLf)
            builder.Append("Response type: " & response.GetType().ToString() & _
                    ControlChars.CrLf)
            builder.Append("Content length: " & response.ContentLength & _
                    " bytes" & ControlChars.CrLf)
            builder.Append("Content type: " & response.ContentType & _
                    ControlChars.CrLf)
            MsgBox(builder.ToString())
    
            Dim stream As Stream = response.GetResponseStream()
            Dim reader As New StreamReader(stream)
            Dim data As String = reader.ReadToEnd()
            reader.Close()
            stream.Close()
            TextBox2.Text = data
        End Sub

  10. #10

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Inet control..

    i need code that complicated? it was just like inet1.openurl("www.google.com",icstring)

    There has to be something less difficult..thx though

  11. #11
    Fanatic Member -TPM-'s Avatar
    Join Date
    Jul 2005
    Posts
    850

    Re: Inet control..

    You just want all the html?
    TPM

    Add yourself to the VBForums Frappr Map!!

  12. #12

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Inet control..

    yeah, no parsing

  13. #13
    Fanatic Member -TPM-'s Avatar
    Join Date
    Jul 2005
    Posts
    850

    Re: Inet control..

    ok then do this:
    Code:
    dim wc as new net.webclient
    dim MyStream as io.stream = wc.openreader("www.google.com")
    dim reader as new io.streamreader(Mystream)
    textbox.text = reader.readtoend
    TPM

    Add yourself to the VBForums Frappr Map!!

  14. #14

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Inet control..

    that doesnt work, gives me this error:
    Could not find file 'C:\Documents and Settings\Jason\Local Settings\Application Data\Temporary Projects\WindowsApplication1\bin\Debug\www.google.com'.

    and it highlights:
    dim MyStream as io.stream = wc.openreader("www.google.com")

  15. #15
    Fanatic Member -TPM-'s Avatar
    Join Date
    Jul 2005
    Posts
    850

    Re: Inet control..

    Opps sorry, you want "http:\\www.google.com"
    TPM

    Add yourself to the VBForums Frappr Map!!

  16. #16

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Inet control..

    that works a charm! Now just to understand what the heck this thing is doing..it doesnt make sense :W

  17. #17
    Fanatic Member -TPM-'s Avatar
    Join Date
    Jul 2005
    Posts
    850

    Re: Inet control..

    Well basically a webclient allows you to connect to a URL. You then use the stream and reader to get the data and stick it in a textbox.
    TPM

    Add yourself to the VBForums Frappr Map!!

  18. #18

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Inet control..

    okay few more..
    Dim MyStream As IO.Stream = ..

    How come i can use io.stream, when it doesnt even show up in the intellisense menu?

    edit **

    also, why doesnt this work:
    VB Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         Dim wc As New Net.WebClient
    3.         Dim MyStream As IO.StreamReader = wc.OpenRead("http://google.com")
    4.         'Dim reader As New IO.StreamReader(MyStream)
    5.         MessageBox.Show(MyStream.ReadToEnd)
    6.     End Sub
    Last edited by |2eM!x; Aug 18th, 2005 at 02:31 PM.

  19. #19

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Inet control..

    please anyone?

  20. #20
    Fanatic Member -TPM-'s Avatar
    Join Date
    Jul 2005
    Posts
    850

    Re: Inet control..

    io.stream doesn't show up in your intellisence? :S What if you do system.io.stream?

    The reason for the streamreader is to convert the byte stream into text.
    TPM

    Add yourself to the VBForums Frappr Map!!

  21. #21

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Inet control..

    no stream doesnt come up anywhy i type it ???

    ill just try and remember i guess..

  22. #22

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Inet control..

    VB Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         Dim wc As New Net.WebClient
    3.         Dim MyStream As IO.Stream = wc.OpenRead("http:\\www.google.com")
    4.         Dim reader As New IO.StreamReader(MyStream)
    5.         MessageBox.Show(reader.ReadToEnd)
    6.     End Sub

    Is how it ended up, thx guys

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width