我想ping代理并获得它的ping时间(例如:41ms)。
我尝试了这个有效的代码,但我没有得到ping时间。
If My.Computer.Network.Ping("216.58.194.51") Then
MsgBox("Success")
Else
MsgBox("Failed")
End If
答案 0 :(得分:-1)
Dim Result As Net.NetworkInformation.PingReply
Dim SendPing As New Net.NetworkInformation.Ping
Dim ResponseTime As Long
Try
Result = SendPing.Send("216.58.194.51")
ResponseTime = Result.RoundtripTime
If Result.Status = Net.NetworkInformation.IPStatus.Success Then
MsgBox(ResponseTime.ToString) 'ResponseTime is response time
Else
End If
Catch ex As Exception
MsgBox("No response")
End Try