Support Forums
[TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Visual Basic and the .NET Framework (https://www.supportforums.net/forumdisplay.php?fid=19)
+---- Thread: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] (/showthread.php?tid=15283)

Pages: 1 2 3


RE: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - andrew - 01-11-2011

Whats wrong with:
Code:
If My.Computer.Network.IsAvailable = True Then
    MsgBox("Computer is connected.")
Else  
    MsgBox("Computer is not connected.")
End If

Much simpler and does the task...


RE: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - Resistance - 01-11-2011

(01-11-2011, 02:37 AM)andrew Wrote: Whats wrong with:
Code:
If My.Computer.Network.IsAvailable = True Then
    MsgBox("Computer is connected.")
Else  
    MsgBox("Computer is not connected.")
End If

Much simpler and does the task...

Thats the n00by way, my way is more accurate hehehehe...


RE: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - KoBE - 01-11-2011

(01-11-2011, 05:17 PM)L3g1tWa5te Wrote: Thats the n00by way, my way is more accurate hehehehe...

That is not the "n00by way". It's actually a very simple way that would work 90% of the time. The only thing wrong with
Code:
If My.Computer.Network.IsAvailable = True Then

is this code will still return true if you have a LAN connection, and no internet connection.

So to make it work 100% of the time, ping the modem to check if it's up. (You could ping google, but in the very slim chance that google went down, this would still work.) So the most accurate way with far less code is to use:.
Code:
If My.Computer.Network.IsAvailable And My.Computer.Network.Ping("192.168.100.1") Then
    'Internet is avail
Else
    'Internet is not avail
End If

WebClient would even produce the same results as WebRequest (used in the OP) but with less code.



RE: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - Resistance - 01-11-2011

(01-11-2011, 09:18 PM)KoBE Wrote:
Code:
If My.Computer.Network.IsAvailable And My.Computer.Network.Ping("192.168.100.1") Then
    'Internet is avail
Else
    'Internet is not avail
End If

Actually, the most accurate way to know if you have any internet access is to would be: 192.168.1.1

Easiest and Fastest method. Figured that on my own Big GrinDD


RE: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - KoBE - 01-11-2011

(01-11-2011, 09:35 PM)L3g1tWa5te Wrote: Actually, the most accurate way to know if you have any internet access is to would be: 192.168.1.1
Easiest and Fastest method. Figured that on my own Big GrinDD

You know that is the default address for linksys routers right?


RE: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - Zyptic - 01-11-2011

Thanks for the tutorial Smile


RE: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - iBored1x1 - 01-12-2011

My way also works, it's smaller and can be modified to set a timeout. (The 2000 is how much time it'll take to try to ping before timing out)

Code:
If My.Computer.Network.Ping("http://www.google.com", 2000) Then
            MsgBox("Connected")
Else
            MsgBox("Not Connected")
End If



RE: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - Resistance - 01-12-2011

(01-12-2011, 03:13 PM)iBored1x1 Wrote: My way also works, it's smaller and can be modified to set a timeout. (The 2000 is how much time it'll take to try to ping before timing out)

Code:
If My.Computer.Network.Ping("http://www.google.com", 2000) Then
            MsgBox("Connected")
Else
            MsgBox("Not Connected")
End If

Ok one more time, here is the best website that should always be up if you have any internet connection: your effing router. 192.168.1.1



RE: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - KoBE - 01-12-2011

(01-12-2011, 08:28 PM)L3g1tWa5te Wrote: Ok one more time, here is the best website that should always be up if you have any internet connection: your effing router. 192.168.1.1

And if you don't use a router? Then your code would definitely fail. Even if you did have a router, you still may not have an internet connection. Once again, your code would fail.


RE: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - Resistance - 01-12-2011

(01-12-2011, 09:38 PM)KoBE Wrote: And if you don't use a router? Then your code would definitely fail. Even if you did have a router, you still may not have an internet connection. Once again, your code would fail.

I already know that when I was typing that response bro, chillax. I was too lazy to think of a another way to use. I suppose google is as good as it gets.