Bojensen Blogs

How to ping an IP address from vb.net

http://www.eggheadcafe.com/software/aspnet/33118839/ping-an-ip-address.aspx

or

   1: Imports System.Net

   2: Imports System.Net.NetworkInformation

   3: Imports System.Text

   4:  

   5: Partial Public Class _Default : Inherits System.Web.UI.Page

   6:     

   7:     Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

   8:  

   9:     End Sub

  10:  

  11:     Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

  12:         Try

  13:             lblStatus.Text = ""

  14:             Dim ping As Ping = New Ping()

  15:             Dim pingreply As PingReply = ping.Send(txtHost.Text)

  16:             txtPing.Text &= "Address: " & pingreply.Address.ToString() & Constants.vbCr

  17:             txtPing.Text &= "Roundtrip Time: " & pingreply.RoundtripTime & Constants.vbCr

  18:             txtPing.Text &= "TTL (Time To Live): " & pingreply.Options.Ttl & Constants.vbCr

  19:             txtPing.Text &= "Buffer Size: " & pingreply.Buffer.Length.ToString() & Constants.vbCr

  20:  

  21:         Catch err As Exception

  22:             lblStatus.Text = err.Message

  23:         End Try

  24:     End Sub

  25: End Class

Comments are closed.