My.Computer.Network.Ping problems

munkee

Active member
Joined
Feb 20, 2007
Messages
43
Programming Experience
Beginner
okay, so here is the code I'm playing with:

VB.NET:
        If My.Computer.Network.Ping("serverAddress", 1000) Then
            MsgBox("Server pinged successfully.")
        Else
            MsgBox("Ping request timed out.")
        End If

That works great and all... but what happens if my Internet Connectivity goes down? Well, the application crashes on me.

Is there a better way to go about this? I've looked around and have only come up with this code (above).

Thanks in advance!

:confused:
 
I figured it out!

VB.NET:
Public Class Form1
    Private Function CompleteProcess() As Boolean

        If My.Computer.Network.Ping("serverAddress") Then
            MsgBox("test runs great!")
        End If

    End Function
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If My.Computer.Network.IsAvailable() Then
            CompleteProcess()
        Else
            MsgBox("test failed")
        End If

    End Sub
End Class
In a previous thread, I was asking how to check network connectivity... So I combined the two and came up with the code above and it works great!
 
excellent solution (i added it to your rep), but im not sure that you need to do CompleteProcess() as a function.

i think i sub would do, since you arent returning anything.

have a good one mate :)
adam
 
Back
Top