Results 1 to 10 of 10

Thread: Ping (System.Net.NetworkInformation) Visual Studio 2005

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2003
    Posts
    42

    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

  2. #2
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    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.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2003
    Posts
    42

    Re: Ping (System.Net.NetworkInformation) Visual Studio 2005

    Quote 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.

  4. #4
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Ping (System.Net.NetworkInformation) Visual Studio 2005

    Quote 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
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2003
    Posts
    42

    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.

  6. #6

    Thread Starter
    Member
    Join Date
    Jun 2003
    Posts
    42

    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.

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  8. #8

    Thread Starter
    Member
    Join Date
    Jun 2003
    Posts
    42

    Re: Ping (System.Net.NetworkInformation) Visual Studio 2005

    Quote 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.

  9. #9
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Ping (System.Net.NetworkInformation) Visual Studio 2005


  10. #10

    Thread Starter
    Member
    Join Date
    Jun 2003
    Posts
    42

    Re: Ping (System.Net.NetworkInformation) Visual Studio 2005

    Quote 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
  •  



Click Here to Expand Forum to Full Width