Error- Type expected

Z

zoneal

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
 
A

Andrew Morton

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top