Sinisterly
[VB.NET]Ping an IP with Response Time - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Visual Basic & .NET Framework (https://sinister.ly/Forum-Visual-Basic-NET-Framework)
+--- Thread: [VB.NET]Ping an IP with Response Time (/Thread-VB-NET-Ping-an-IP-with-Response-Time)



[VB.NET]Ping an IP with Response Time - Sapientia - 07-17-2013

Alright, so lets add to our form: 2 Labels, 2 TextBox Controls and 1 Button. Make your form look something along the lines of this:
[Image: o5U1HmC.png]

View the code for your project, and paste this function in:
Code:
Public Function Ping(ByVal server As String) As String
        Dim ElapseTime As New Stopwatch
        ElapseTime.Start()
        My.Computer.Network.Ping(server)
        ElapseTime.Stop()
        Return ElapseTime.Elapsed.TotalSeconds.ToString("N")
    End Function

Go back to your design, double click your button and paste this code:
Code:
TextBox2.Text = Ping(TextBox1.Text) & " Seconds"

If you did it correct, you should see something like this:
[Image: DOF8d4I.png]


RE: [VB.NET]Ping an IP with Response Time - Eternity - 07-17-2013

I think it should be 0.33 Secs and not 0.33 MS.
But good work Smile


RE: [VB.NET]Ping an IP with Response Time - Sapientia - 07-17-2013

Oh, whoops. Thanks for pointing that out Smile