|
-
Mar 18th, 2008, 01:10 PM
#1
Thread Starter
Member
Ping (System.Net.NetworkInformation) Visual Studio 2005
Hey guys, I am trying to create a new ping program in Visual Studio 2005. And I need alittle help. After doing alittle reading/research I have come up with this.
Imports System.Net.NetworkInformation
'
Public Class frmMain
'
Dim p As Ping
Dim pReply As PingReply
'
Private Sub btnPing_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPing.Click
Try
p = New Ping
pReply = p.Send(txtAddress.Text)
lblStatus.Text = pReply.Status.ToString
Catch pExc As PingException
MessageBox.Show(pExc.InnerException.Message)
End Try
End Sub
This line here "lblStatus.Text = pReply.Status.ToString" What I would like to happen is. If the reply is "Success" <--- then this should display in the color green. If they reply is "Failed" then I would like this color to be red. Any idea's on how I can acomplish this ?
Thanks
ScarEye
-
Mar 18th, 2008, 01:17 PM
#2
Re: Ping (System.Net.NetworkInformation) Visual Studio 2005
You'll either be setting the forecolor or backcolor depending on your meaning. Forecolor for the text, backcolor for the box. e.g.
lblStatus.BackColor = Color.Green
Last edited by dbasnett; Mar 18th, 2008 at 01:21 PM.
-
Mar 18th, 2008, 01:20 PM
#3
Thread Starter
Member
Re: Ping (System.Net.NetworkInformation) Visual Studio 2005
 Originally Posted by dbasnett
You'll either be setting the forecolor or backcolor depending on your meaning. Forecolor for the text, backcolor for the box.
dbasnett,
Thanks for your reply. But can you help me with the code. I should have specified that I am a newb at this.
Thanks for your quick reply. Keep in mind depending on the reply it will be either Green(Success) or Red(Failed)
So, in a nutshell if
pReply.Status.ToString = Success (GREEN)
pReply.Status.ToString = Failed (RED)
ScarEye
Last edited by ScarEye; Mar 18th, 2008 at 01:25 PM.
-
Mar 18th, 2008, 01:42 PM
#4
Re: Ping (System.Net.NetworkInformation) Visual Studio 2005
 Originally Posted by ScarEye
dbasnett,
Thanks for your reply. But can you help me with the code. I should have specified that I am a newb at this.
Thanks for your quick reply. Keep in mind depending on the reply it will be either Green(Success) or Red(Failed)
So, in a nutshell if
pReply.Status.ToString = Success (GREEN)
pReply.Status.ToString = Failed (RED)
ScarEye
Code:
lblStatus.Text = pReply.Status.ToString
if preply.status = ??? then ' you need the code for success at ???
lblStatus.BackColor = Color.Green
else
lblStatus.BackColor = Color.Red
end if
-
Mar 18th, 2008, 02:00 PM
#5
Thread Starter
Member
Re: Ping (System.Net.NetworkInformation) Visual Studio 2005
dbasnett,
THANK YOU A MILLION BRO. I can't express how grateful I am. I have one more question. I am going to ask in a minute.
-
Mar 18th, 2008, 02:16 PM
#6
Thread Starter
Member
Re: Ping (System.Net.NetworkInformation) Visual Studio 2005
Okay, here is my question. I am going to have about 20 IP's to ping. What is the most fastest efficient way of doing this. Any help/code is greatly appreciated.
So I will have 20 Text Address Box (IP's will go here) and 20 Label Box (Success or Failed) will go here. So when the user clicks on the
"Ping Button" it should just cycle through all the IP's and get the results.
Thanks In Advance
ScarEye
Last edited by ScarEye; Mar 18th, 2008 at 02:36 PM.
-
Mar 18th, 2008, 02:45 PM
#7
Re: Ping (System.Net.NetworkInformation) Visual Studio 2005
Kick off a series of asynchronous threads, each one pinging one of the IP addresses, and returning a result.
-
Mar 18th, 2008, 03:04 PM
#8
Thread Starter
Member
Re: Ping (System.Net.NetworkInformation) Visual Studio 2005
 Originally Posted by mendhak
Kick off a series of asynchronous threads, each one pinging one of the IP addresses, and returning a result.
mendhak,
Thanks for your quick reply, judging by your name you seem to be Desi.
Anyway, I was reading about asynchronous threading, can you (or anyone) give me an example on how I can do this with my code ?
The IP's I will be using are as follows:
192.168.1.1
192.168.2.1
192.168.3.1
All the way through 192.168.20.1
Thanks In Advance
ScarEye
Last edited by ScarEye; Mar 18th, 2008 at 03:09 PM.
-
Mar 18th, 2008, 05:38 PM
#9
Re: Ping (System.Net.NetworkInformation) Visual Studio 2005
-
Mar 18th, 2008, 05:53 PM
#10
Thread Starter
Member
Re: Ping (System.Net.NetworkInformation) Visual Studio 2005
 Originally Posted by mendhak
Thanks, I will read through that doc.
Thanks for your time, I really appreciate it.
ScarEye
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|