[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) |
[TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - Resistance - 01-02-2011 Hey guys. I have not posted a tutorial in weeks. So I thought this thread would be very helpful; A lot of VB applications I make need an active internet connection in order to work, so we will use a function to detect whether theres an active internet connection at the moment or not. This can help prevent fatal errors while the application requires internet when trying to run something when there is no internet connection. Heres the code, first plug in the Function anywhere between 2 classes as in "Form1_Load and CheckBox1_CheckState." Function We Are Using: Code: Public Function IsConnectionAvailibe() As Boolean Now to manipulate the code a little bit: Code: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Now obviously you may change it from Form1_Load to a BackroundWorker or Timer. Thats just me. Enjoy! Post replies if you have questions! RE: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - Thyonic - 01-03-2011 Great code. Personally, I'd just ping a network using My.Computer.Network.Ping, like google for example, and check the return value. A lot simpler and less code. Regardless, yours is great. RE: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - Break - 01-05-2011 Really good code but it could be shorter. RE: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - w00pz - 01-08-2011 Thanks for the tutorial And great code! RE: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - Fragma - 01-08-2011 Hell of a lot of code for such a simple task. RE: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - Resistance - 01-08-2011 (01-08-2011, 05:57 PM)Fragma Wrote: Hell of a lot of code for such a simple task. Excuse me for living! lol This is one of the most efficient ways to verify a solid internet connection. RE: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - ven0m - 01-08-2011 thanks for the tutorial. great job. ~ven0m RE: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - Modest - 01-09-2011 You should Never use try/catch to work out if something like the internet connection is available, always handle the return value! RE: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - Resistance - 01-09-2011 (01-09-2011, 06:48 PM)Modest Wrote: You should Never use try/catch to work out if something like the internet connection is available, always handle the return value! ...No thanks, i'd stick to my piece of code thank you. And there are NO returns to be handled that are displayed, in my awesome code. We use the try, catch ex as exception, and end try. It is my way to go, it is the safest way to go. You only have 5 posts non the less, a true Learner. See ya later alligator. RE: [TuToRiAl] How to Check if theres any Internet Connection [TuToRiAl] - BizzyX - 01-09-2011 This is alot of code for a simple task ^^ but good job on this bro. |