By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,168 Members | 2,598 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,168 IT Pros & Developers. It's quick & easy.

INet equivalent in vb.net

P: n/a
Hello Group,
All I wanna do is to get the contents of a web page and
display it in my application. VB 6.0 has the INet control. How do I do it
using VB.NET/

Thanks for the help,
Chris.
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I am sure there are plenty of examples on the web if you google for
system.web

"chris" <ch***@nospam.com> wrote in message
news:uJ**************@TK2MSFTNGP11.phx.gbl...
Hello Group,
All I wanna do is to get the contents of a web page and
display it in my application. VB 6.0 has the INet control. How do I do it
using VB.NET/

Thanks for the help,
Chris.

Nov 20 '05 #2

P: n/a
Hi Chris,

Thanks for using Microsoft MSDN Managed Newsgroup. My name is Peter, and I
will be assisting you on this issue.

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to get the content of a
web page in VB.NET.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I think the WebClient class will be a good choice. The link below also
include a sample.
WebClient.DownloadData Method
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemnetwebclientclassdownloaddatatopic.asp

Or you may try to use the HttpWebRequest class which will give more
flexible function.
HttpWebRequest Class
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemnethttpwebrequestclasstopic.asp
<sample>
Imports System.Net
Imports System.Text
Imports System.IO
Module Module2
Public Sub Main()
Dim url As String = "http://www.google.com"
' Creates an HttpWebRequest for the specified URL.
Dim myHttpWebRequest As HttpWebRequest =
CType(WebRequest.Create(url), HttpWebRequest)
' Sends the request and waits for a response.
Dim myHttpWebResponse As HttpWebResponse =
CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
' Calls the method GetResponseStream to return the stream
associated with the response.
Dim receiveStream As Stream = myHttpWebResponse.GetResponseStream()
Dim encode As Encoding = System.Text.Encoding.GetEncoding("utf-8")
' Pipes the response stream to a higher level stream reader with
the required encoding format.
Dim readStream As New StreamReader(receiveStream, encode)
Console.WriteLine(ControlChars.Lf + ControlChars.Cr + "Response
stream received")
Dim read(256) As [Char]
' Reads 256 characters at a time.
Dim count As Integer = readStream.Read(read, 0, 256)
Console.WriteLine("HTML..." + ControlChars.Lf + ControlChars.Cr)
While count > 0
' Dumps the 256 characters to a string and displays the string
to the console.
Dim str As New [String](read, 0, count)
Console.Write(str)
count = readStream.Read(read, 0, 256)
End While
Console.WriteLine("")
' Releases the resources of the Stream.
readStream.Close()
' Releases the resources of the response.
myHttpWebResponse.Close()
End Sub
End Module
</sample>

Please try the link above and let me if that answer your question.
If you have any concern on this question, please post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #3

P: n/a
Peter Huang,
Thanks for the help:-)
Chris.

"Peter Huang" <v-******@online.microsoft.com> wrote in message
news:wO**************@cpmsftngxa07.phx.gbl...
Hi Chris,

Thanks for using Microsoft MSDN Managed Newsgroup. My name is Peter, and I
will be assisting you on this issue.

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to get the content of a
web page in VB.NET.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I think the WebClient class will be a good choice. The link below also
include a sample.
WebClient.DownloadData Method
http://msdn.microsoft.com/library/de...us/cpref/html/ frlrfsystemnetwebclientclassdownloaddatatopic.asp

Or you may try to use the HttpWebRequest class which will give more
flexible function.
HttpWebRequest Class
http://msdn.microsoft.com/library/de...us/cpref/html/ frlrfsystemnethttpwebrequestclasstopic.asp
<sample>
Imports System.Net
Imports System.Text
Imports System.IO
Module Module2
Public Sub Main()
Dim url As String = "http://www.google.com"
' Creates an HttpWebRequest for the specified URL.
Dim myHttpWebRequest As HttpWebRequest =
CType(WebRequest.Create(url), HttpWebRequest)
' Sends the request and waits for a response.
Dim myHttpWebResponse As HttpWebResponse =
CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
' Calls the method GetResponseStream to return the stream
associated with the response.
Dim receiveStream As Stream = myHttpWebResponse.GetResponseStream() Dim encode As Encoding = System.Text.Encoding.GetEncoding("utf-8")
' Pipes the response stream to a higher level stream reader with
the required encoding format.
Dim readStream As New StreamReader(receiveStream, encode)
Console.WriteLine(ControlChars.Lf + ControlChars.Cr + "Response
stream received")
Dim read(256) As [Char]
' Reads 256 characters at a time.
Dim count As Integer = readStream.Read(read, 0, 256)
Console.WriteLine("HTML..." + ControlChars.Lf + ControlChars.Cr)
While count > 0
' Dumps the 256 characters to a string and displays the string
to the console.
Dim str As New [String](read, 0, count)
Console.Write(str)
count = readStream.Read(read, 0, 256)
End While
Console.WriteLine("")
' Releases the resources of the Stream.
readStream.Close()
' Releases the resources of the response.
myHttpWebResponse.Close()
End Sub
End Module
</sample>

Please try the link above and let me if that answer your question.
If you have any concern on this question, please post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.