|
-
Aug 18th, 2005, 10:08 AM
#1
Thread Starter
Admodistrator
Inet control..
I cant seem to find it, what is its name in .net?
-
Aug 18th, 2005, 11:06 AM
#2
Addicted Member
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?
-
Aug 18th, 2005, 11:15 AM
#3
Thread Starter
Admodistrator
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 ?
-
Aug 18th, 2005, 11:20 AM
#4
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!!
-
Aug 18th, 2005, 11:28 AM
#5
Thread Starter
Admodistrator
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
-
Aug 18th, 2005, 11:31 AM
#6
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!!
-
Aug 18th, 2005, 11:37 AM
#7
Thread Starter
Admodistrator
Re: Inet control..
Okay, gotcha now...Just i dont know which option to use
-
Aug 18th, 2005, 11:39 AM
#8
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!!
-
Aug 18th, 2005, 11:41 AM
#9
Addicted Member
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
-
Aug 18th, 2005, 11:56 AM
#10
Thread Starter
Admodistrator
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
-
Aug 18th, 2005, 12:09 PM
#11
Re: Inet control..
You just want all the html?
TPM
Add yourself to the VBForums Frappr Map!!
-
Aug 18th, 2005, 12:49 PM
#12
Thread Starter
Admodistrator
-
Aug 18th, 2005, 12:55 PM
#13
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!!
-
Aug 18th, 2005, 02:00 PM
#14
Thread Starter
Admodistrator
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")
-
Aug 18th, 2005, 02:03 PM
#15
Re: Inet control..
Opps sorry, you want "http:\\www.google.com"
TPM
Add yourself to the VBForums Frappr Map!!
-
Aug 18th, 2005, 02:15 PM
#16
Thread Starter
Admodistrator
Re: Inet control..
that works a charm! Now just to understand what the heck this thing is doing..it doesnt make sense :W
-
Aug 18th, 2005, 02:19 PM
#17
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!!
-
Aug 18th, 2005, 02:28 PM
#18
Thread Starter
Admodistrator
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:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim wc As New Net.WebClient
Dim MyStream As IO.StreamReader = wc.OpenRead("http://google.com")
'Dim reader As New IO.StreamReader(MyStream)
MessageBox.Show(MyStream.ReadToEnd)
End Sub
Last edited by |2eM!x; Aug 18th, 2005 at 02:31 PM.
-
Aug 18th, 2005, 05:57 PM
#19
Thread Starter
Admodistrator
-
Aug 18th, 2005, 06:06 PM
#20
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!!
-
Aug 18th, 2005, 06:34 PM
#21
Thread Starter
Admodistrator
Re: Inet control..
no stream doesnt come up anywhy i type it ???
ill just try and remember i guess..
-
Aug 18th, 2005, 08:00 PM
#22
Thread Starter
Admodistrator
Re: Inet control..
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim wc As New Net.WebClient
Dim MyStream As IO.Stream = wc.OpenRead("http:\\www.google.com")
Dim reader As New IO.StreamReader(MyStream)
MessageBox.Show(reader.ReadToEnd)
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|