Hi![]()
I am using VB.Net 2002. I have the following code that works but takes too much time to execute. Any another way (that works).
'Here’s how you might use this function in your application:VB Code:
Public Function IsConnectionAvailable() As Boolean ' Returns True if connection is available ' Replace [url]www.yoursite.com[/url] with a site that ' is guaranteed to be online - perhaps your ' corporate site, or microsoft.com Dim objUrl As New System.Uri("http://www.yoursite.com/") ' Setup WebRequest Dim objWebReq As System.Net.WebRequest objWebReq = System.Net.WebRequest.Create(objUrl) Dim objResp As System.Net.WebResponse Try ' Attempt to get response and return True objResp = objWebReq.GetResponse objResp.Close() objWebReq = Nothing Return True Catch ex As Exception ' Error, exit and return False objResp.Close() objWebReq = Nothing Return False End Try End Function
VB Code:
If IsConnectionAvailable() = True Then MessageBox.Show("You are online!") End If


).
Reply With Quote

