Open URL and read page  
Author Message
PlusNet





PostPosted: Fri Jan 14 11:27:09 CST 2005 Top

Visual Basic [VB] >> Open URL and read page

Hi
In vb 6 there was a control you could use to open a url, set the time
out and read the resulting page.
how is this done in VB.Net?

Thanks

Visual Studio297  
 
 
Herfried





PostPosted: Fri Jan 14 11:27:09 CST 2005 Top

Visual Basic [VB] >> Open URL and read page
> In vb 6 there was a control you could use to open a url, set the time
> out and read the resulting page.
> how is this done in VB.Net?

\\\
Imports System.IO
Imports System.Net
.
.
.
Public Function LoadTextFile(ByVal Url As String) As String
Dim wrq As WebRequest = WebRequest.Create(Url)
Dim wrp As HttpWebResponse = _
DirectCast(wrq.GetResponse(), HttpWebResponse)
Dim sr As New StreamReader(wrp.GetResponseStream)
Dim Text As String = sr.ReadToEnd()
sr.Close()
wrp.Close()
Return Text
End Function
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


 
 
Adrian





PostPosted: Fri Jan 14 12:21:11 CST 2005 Top

Visual Basic [VB] >> Open URL and read page Great Thanks




>> In vb 6 there was a control you could use to open a url, set the time
>> out and read the resulting page.
>> how is this done in VB.Net?
>
> \\\
> Imports System.IO
> Imports System.Net
> .
> .
> .
> Public Function LoadTextFile(ByVal Url As String) As String
> Dim wrq As WebRequest = WebRequest.Create(Url)
> Dim wrp As HttpWebResponse = _
> DirectCast(wrq.GetResponse(), HttpWebResponse)
> Dim sr As New StreamReader(wrp.GetResponseStream)
> Dim Text As String = sr.ReadToEnd()
> sr.Close()
> wrp.Close()
> Return Text
> End Function
> ///
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
>