/ Published in: VB.NET
This is a simple function to test for an internet connection. Originally grabbed from "devbuzz" at the devbuzz forums (see link) and now modified for VB.NET 3.5
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Public Function GotInternet() As Boolean Dim req As System.Net.HttpWebRequest Dim res As System.Net.HttpWebResponse GotInternet = False Try req = CType(System.Net.HttpWebRequest.Create("http://www.google.com"), System.Net.HttpWebRequest) res = CType(req.GetResponse(), System.Net.HttpWebResponse) req.Abort() If res.StatusCode = System.Net.HttpStatusCode.OK Then GotInternet = True End If Catch weberrt As System.Net.WebException GotInternet = False Catch except As Exception GotInternet = False End Try End Function
URL: http://forums.devbuzz.com/tm.asp?m=15988&p=1&tmode=1