Visual Studio Development Bookmark and Share   
 index > Visual Basic Express Edition > How to ping a ip every minute and show results in a form.
 

How to ping a ip every minute and show results in a form.

I'm trying to ping a ip and show the results in a form. I can ping a address and display results in a textbox, but I don't know how to do a ping every minute to get updated results. I'm also trying to send an email to myself if a ip can't be reached. Can someone help me on this? Thanks.
Vinsons  Tuesday, July 01, 2008 9:13 PM

Public Class Form1

Protected Friend withevents tmr as new timer

Private png as new System.Net.NetworkInformation.ping

Public Sub Form1_load(byval sender as object, byval e as system.eventargs) Handles mybase.load

tmr.stop : tmr.interval = 60* 1000 : Tmr.start

End Sub

Private Sub tmr_tick(byval sender as object, byval e as system.eventargs) Handles tmr.tick

tmr.stop

Dim pr as System.Net.NetworkInformation.pingreply

Try

pr = png.send("www.microsoft.com")

Select Casepr.status

case System.Net.Networkinformation.IpStatus.Success

Textbox1.text = "ok"

case else

Textbox1.text = "Error" ' Note more information than this is available

end select ' See Object Browser

catch ex as exception

Textbox1.text = "Error " + ex.message

Finally

tmr.start

End try

End Sub

End Class

ReneeC  Tuesday, July 01, 2008 10:27 PM

Public Class Form1

Protected Friend withevents tmr as new timer

Private png as new System.Net.NetworkInformation.ping

Public Sub Form1_load(byval sender as object, byval e as system.eventargs) Handles mybase.load

tmr.stop : tmr.interval = 60* 1000 : Tmr.start

End Sub

Private Sub tmr_tick(byval sender as object, byval e as system.eventargs) Handles tmr.tick

tmr.stop

Dim pr as System.Net.NetworkInformation.pingreply

Try

pr = png.send("www.microsoft.com")

Select Casepr.status

case System.Net.Networkinformation.IpStatus.Success

Textbox1.text = "ok"

case else

Textbox1.text = "Error" ' Note more information than this is available

end select ' See Object Browser

catch ex as exception

Textbox1.text = "Error " + ex.message

Finally

tmr.start

End try

End Sub

End Class

ReneeC  Tuesday, July 01, 2008 10:27 PM
This code works great. Thanks for your help!

Vinsons  Wednesday, July 02, 2008 1:20 PM

Great !

I wrote that by hand.....

ReneeC  Wednesday, July 02, 2008 1:26 PM

Just about every answer I get from ya works first time.

Vinsons  Wednesday, July 02, 2008 1:29 PM

may i know how to stop pinging? for example, the ip will be ping every 15 minutes and then user can stop the ping proces by click the stop ping button....is it possible?

ainadeck  Tuesday, August 26, 2008 9:12 AM

You can use google to search for other answers

Custom Search

More Threads

• HOW TO: Saving data into a remote computer through internet
• Caught in the backwash.
• Trouble running a program
• Problems printing from datagridview - what am I doing wrong here?
• Is the close command necessary after reading from a text file?
• TInterface: great invitation to genetic engOneers to Express edition? Or just sla0t?
• best way to foudn all if webbrowser is totally ready
• Needing help
• About MDI child
• BindingNavugatir Code