467,923 Members | 1,328 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,923 developers. It's quick & easy.

Error- Type expected

Hi

I am trying to get html response from a web server for a given URL .
I have written following code.

Imports System.Net
Imports System.IO

Dim objRequest As HTTPWebRequest =
WebRequest.Create("http://www.google.com")
Dim result As String
objRequest.Method = "GET"
Dim objResponse As HttpWebResponse = objRequest.GetResponse()
Dim sr As StreamReader
sr = New StreamReader(objResponse.GetResponseStream())
result = sr.ReadToEnd()
sr.Close()
Dim oFile As File
Dim oWrite As StreamWriter
oWrite = oFile.CreateText("C:/Windows/temp/google.txt")
oWrite.Write(result)
oWrite.Close()
When I try to compile this I am getting an error "Type not defined" for
HttpWebRequest. Can anyone plz help me to resolve this error

Thanks

Jan 23 '06 #1
  • viewed: 1539
Share:
1 Reply
zo****@yahoo.com wrote:
I am trying to get html response from a web server for a given URL .
I have written following code.

Imports System.Net
Imports System.IO

Dim objRequest As HTTPWebRequest =
WebRequest.Create("http://www.google.com")
Dim result As String
objRequest.Method = "GET"
Dim objResponse As HttpWebResponse = objRequest.GetResponse()
Dim sr As StreamReader
sr = New StreamReader(objResponse.GetResponseStream())
result = sr.ReadToEnd()
sr.Close()
Dim oFile As File
Dim oWrite As StreamWriter
oWrite = oFile.CreateText("C:/Windows/temp/google.txt")
oWrite.Write(result)
oWrite.Close()
When I try to compile this I am getting an error "Type not defined"
for HttpWebRequest. Can anyone plz help me to resolve this error


Try this:-

Dim objReq as WebRequest
try
objReq=WebRequest.Create("http://www.google.com")
catch
' it couldn't compose the URL
end try

Andrew
Jan 23 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Aravind | last post: by
1 post views Thread by yanwan | last post: by
2 posts views Thread by Gregory | last post: by
1 post views Thread by developer | last post: by
15 posts views Thread by madhu.ab | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.