Replacement for Inet Control

  • Thread starter Thread starter Jerry Spence1
  • Start date Start date
J

Jerry Spence1

The following seemed so easy in VB6

Inet2.URL = HTTP://192.168.0.200/get?brightness

Dim retval As String = AxInet2.OpenURL


This would give me the string 'Brightness=34' (It's from a camera)

How do I do it with VB.Net (2005)? I've trawled through loads of code using
Webrowsers, HTTPWepresponse etc but can't get a result.

-Jerry
 
Dim URI As String = "HTTP://192.168.0.200/get?brightness"

Dim wbClient As New WebClient
Dim strData As Stream = wbClient.OpenRead(URI)
Dim sr As StreamReader = New StreamReader(strData)

the return data is now in the streamreader ( use the sr `s methods to
retreive the data in the desired format )

note that you need to set up a proxy object and bind this to the webclient
if you are behind a proxy server

regards

Michel Posseth [MCP]
 
"can't get a result". Do you mean you have an error or that you just don't
get any response ?

Seeing some code could help. System.Net.WebClient is likely the easiest path
for now. For example :
Dim w As New System.Net.WebClient
MsgBox(w.DownloadString("http://www.google.com/"))
w.Dispose()



Is the target page under your control ? For example a site could perhaps
return nothing at all if the user agant is empty...
 
Back
Top