![]() |
|
[.NET] pinger in vb - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] pinger in vb (/showthread.php?tid=5066832) |
pinger in vb - BigMre - Nov 22, 2015 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. * - Odus - Nov 22, 2015 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. * - BigMre - Nov 22, 2015 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 |