Check Internet Connection *IsAvailable*

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
6 posts Page 1 of 1
Contributors
User avatar
riottechtalk
New Member
New Member
Posts: 11
Joined: Sat Feb 19, 2011 4:12 am

how to check if you have internet.
you will need one button

once you have 1 button, double click and enter this code:
Code: Select all
If My.Computer.Network.IsAvailable = True Then
            MsgBox("Computer is connected.")
         If My.Computer.Network.IsAvaliable = False Then
            MsgBox("Computer is not connected.")
        End If
hope this helped! (someone posted this, i just edited this a bit. this is more useful in webbrowsers than the original code that i received.)
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

try this:

OK,
This is what I was tring to do.
Code: Select all
   Private Function IsConnectionAvailable() As Boolean
        //Call url
        //"http://www.MyServer.com"
        //"http://XXX.XXX.XXX.XXX:XXXX"  Port Numbers can be used
        Dim url As New System.Uri("http://www.MyServeraddress_OR_IP:PORT.com/")
        //Request for request
        Dim req As System.Net.WebRequest
        req = System.Net.WebRequest.Create(url)
        Dim resp As System.Net.WebResponse
        Try
            resp = req.GetResponse()
            resp.Close()
            req = Nothing
            Return True
        Catch ex As Exception
            req = Nothing
            Return False
        End Try
    End Function

If IsConnectionAvailable() = True Then
     //Your code to the Add-Ins "NORMAL" load event goes here
else 
     //The code if for what you want to happen if server is offline.
     MsgBox("Sorry! The server is offline right now. Please try back later.")
End IF
Last edited by Scottie1972 on Sat Feb 19, 2011 11:08 pm, edited 1 time in total.
Image
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

My.Computer.Network.IsAvaliable is not used to detect an internet connection, it just checks the local network interface.

Edit: Scottie's method should work.
Last edited by mandai on Sun Feb 20, 2011 2:03 pm, edited 1 time in total.
User avatar
riottechtalk
New Member
New Member
Posts: 11
Joined: Sat Feb 19, 2011 4:12 am

mandai wrote:
That link doesn't work.
My.Computer.Network.IsAvaliable is not used to detect an internet connection, it just checks the local network interface.
oh, then i shall delete topic :)
User avatar
code it
VIP - Site Partner
VIP - Site Partner
Posts: 821
Joined: Sun Oct 10, 2010 3:02 pm

Ask a moderator or admin but nice tutorial anyways cooll; cooll;
User avatar
riottechtalk
New Member
New Member
Posts: 11
Joined: Sat Feb 19, 2011 4:12 am

code it wrote:
Ask a moderator or admin but nice tutorial anyways cooll; cooll;
yeah i did... it would help if you could too :)
thx!
6 posts Page 1 of 1
Return to “Tutorials”