Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

pinger in vb

Dim IP As String
IP = pingip.Text
online.Visible = False
off.Visible = False

If My.Computer.Network.Ping(IP) Then
online.Visible = True
Else
off.Visible = True
End If


so the problem is: if i dont write in a ip that looks like this: (127.0.0.1 etc) the programm crash.
So the question is really error trapping? Well you have a couple of options.
1) Try and parse the IP, act on result.
2) Use a MaskedTextBox and set the format yourself
3) Catch the invalid format exception and report back

I say go for 1 or 2.
thx, but i am a noob.

MaskedTextBox i dont know how to use it
i want to say, that you only can put in numbers and if nothing is in there you cant start it..


If pingip.Text = ("") Then
MsgBox("Please put in a IP Adress in this Format:(127.0.0.1")
Else
Dim IP As String
IP = pingip.Text
online.Visible = False
off.Visible = False

If My.Computer.Network.Ping(IP) Then
online.Visible = True
Else
off.Visible = True
End If
End If


got it thanks :DDDDD

haha


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by umami smokes shishaJan 16, 2017 08:40 AM 176 4,695 Jan 16, 2017 08:40 AM
Last Post: Xogg
[C#] by ioncanon667Apr 15, 2016 04:13 PM 2 185 Apr 15, 2016 04:13 PM
Last Post: Odus
[.NET] by oRequiemJul 20, 2014 12:48 AM 9 300 Jul 20, 2014 12:48 AM
Last Post: oRequiem