Guardians | Ping IP + Receive Response Time 08-30-2013, 03:56 AM
#1
Hey there Discussion Zone! Today, I'm going to be showing you guys how to basically ping an IP Address and also receive the time it took for the server/website/connection to respond to your request.
Firstly, create a new project, and name it whatever you want.. mine will be called 'PingRequest.' Once you have done this add 1 textbox, 2 labels, and 1 button to your form like so...
![[Image: bcCPoAI.png]](http://i.imgur.com/bcCPoAI.png)
Next, we are going to double click the forum to go to the code view, and paste this function somewhere in the coding.
This will create the function so that when we click the button it will ping the value of server which we will do next. Now, we are going to go back to design view and double click the button..
We are simply going to type one line of code that will ping the server, and print the response time on a label. When you receive the response it will be printed out as a decimal, and the unit that will be following will be MS which stands for MilliSeconds. So say mine was 35ms that would mean it took my connection 35 Milliseconds to respond which is about 0.035 seconds.
Basically, if you did it right you should see something like this:
![[Image: icTeh9X.png]](http://i.imgur.com/icTeh9X.png)
This concludes our tutorial, thanks for reading!
Firstly, create a new project, and name it whatever you want.. mine will be called 'PingRequest.' Once you have done this add 1 textbox, 2 labels, and 1 button to your form like so...
![[Image: bcCPoAI.png]](http://i.imgur.com/bcCPoAI.png)
Next, we are going to double click the forum to go to the code view, and paste this function somewhere in the coding.
Code:
Public Function Ping(ByVal server As String) As String
Dim s As New Stopwatch
s.Start()
My.Computer.Network.Ping(server)
s.Stop()
Return s.Elapsed.TotalSeconds.ToString("N")
End Function
This will create the function so that when we click the button it will ping the value of server which we will do next. Now, we are going to go back to design view and double click the button..
We are simply going to type one line of code that will ping the server, and print the response time on a label. When you receive the response it will be printed out as a decimal, and the unit that will be following will be MS which stands for MilliSeconds. So say mine was 35ms that would mean it took my connection 35 Milliseconds to respond which is about 0.035 seconds.
Code:
Label2.Text = "Response Time: " & Ping(TextBox1.Text) & " MS"
Basically, if you did it right you should see something like this:
![[Image: icTeh9X.png]](http://i.imgur.com/icTeh9X.png)
This concludes our tutorial, thanks for reading!
![[Image: GiXvY27.png]](http://i.imgur.com/GiXvY27.png)