Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9255927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:49:14+00:00 2026-06-18T11:49:14+00:00

I am having an issue where I get multiple entries in my ListView for

  • 0

I am having an issue where I get multiple entries in my ListView for the same item if I run my action more than once.

I am creating a simple network scanner/hostname grabber that will add the items to the listview as they come back alive to my ping test.

When I run it the first time it runs fine and creates one entry as it should.

When I run it subsequent times it creates the item as many times as I have ran the code ex. 3rd time hitting start it creates each entry 3 times when it should just create the entry once.

Here is my go button code:

 Private Sub Go_Click(sender As Object, e As EventArgs) Handles Go.Click
        Dim verifyIP
        ListView1.Items.Clear()
        chkDone = 0
        verifyIP = ipChk(ipAdd.Text)
        If verifyIP = 1 Then
            ipAddy = Split(ipAdd.Text, ".")
            pingTest1.WorkerReportsProgress = True
            pingTest1.WorkerSupportsCancellation = False
            AddHandler pingTest1.ProgressChanged, AddressOf pingTest1_ProgressChanged
            pingTest1.RunWorkerAsync()
            pingTest2.WorkerReportsProgress = True
            pingTest2.WorkerSupportsCancellation = False
            AddHandler pingTest2.ProgressChanged, AddressOf pingTest2_ProgressChanged
            pingTest2.RunWorkerAsync()
            pingTest3.WorkerReportsProgress = True
            pingTest3.WorkerSupportsCancellation = False
            AddHandler pingTest3.ProgressChanged, AddressOf pingTest3_ProgressChanged
            pingTest3.RunWorkerAsync()
            pingTest4.WorkerReportsProgress = True
            pingTest4.WorkerSupportsCancellation = False
            AddHandler pingTest4.ProgressChanged, AddressOf pingTest4_ProgressChanged
            pingTest4.RunWorkerAsync()
            While chkDone < 4
                wait(25)
            End While
        Else
            MsgBox("IP Invalid")
        End If
        MsgBox("Done")
    End Sub

Here is the code from one of the background workers I am using:

Private WithEvents pingTest1 As BackgroundWorker = New BackgroundWorker

    Private Sub pingTest1_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs) Handles pingTest1.DoWork
        Try
            Dim hostCheck
            pingResult1 = 0
            pingTestDone1 = 0
            tryIP1 = ipAddy(0) & "." & ipAddy(1) & "." & ipAddy(2) & ".1"
            If My.Computer.Network.Ping(tryIP1) = True Then
                'Dim pingsender As New Net.NetworkInformation.Ping
                'If pingsender.Send(tryIP).Status = Net.NetworkInformation.IPStatus.Success Then
                Try
                    'Dim host As System.Net.IPHostEntry
                    hostCheck = ""
                    'host = System.Net.Dns.GetHostByAddress(tryIP3)
                    'MsgBox(host.HostName)
                    'host3 = host.HostName
                    'hostCheck = System.Net.Dns.GetHostEntry(tryIP3).HostName
                    hostCheck = System.Net.Dns.GetHostByAddress(tryIP1)
                    'get the hostname property 
                    hostCheck = hostCheck.HostName
                    pingTest1.ReportProgress("1", hostCheck)
                Catch f As Exception
                    'MsgBox("Error: " & f.Message)
                    pingTest1.ReportProgress("1", "No Hostname Found")
                End Try
            Else
                pingResult1 = 2
            End If
        Catch d As Exception
            MsgBox("There was an error trying to ping the IP Address: " & d.Message)
        End Try
    End Sub

    Private Sub pingTest1_ProgressChanged(e.ByVal sender As Object, ByVal e As ProgressChangedEventArgs)
        MsgBox("Hey")
        Dim str(2) As String
        Dim itm As ListViewItem
        str(0) = tryIP1 & " Is Alive!!!"
        str(1) = e.UserState
        itm = New ListViewItem(str)
        ListView1.Items.Add(itm)
        str(0) = ""
        str(1) = ""
        itm = Nothing
    End Sub

Private Sub pingTest1_RunWorkerCompleted(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs) Handles pingTest1.RunWorkerCompleted
    chkDone = chkDone + 1
End Sub
  • I added the Hey box and sure enough the ProgressChanged event gets triggered the amount of times I have hit the Go button. Is it something I have coded incorrectly?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:49:15+00:00Added an answer on June 18, 2026 at 11:49 am

    It’s most likely because you’re adding, but not removing your handlers for the progress changed, so you’re handling the event multiple times.

    Try adding your Progress Changed Event Handlers when you’re instantiating your Background workers, rather than every time you click your button. This way they will only handled once.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't get past this issue I am having. Here's a simple example: class
I am having an issue where I cannot get the same bit of CSS
The issue I'm having is issue with is I'm trying to get the paintComponent
I'm having an issue here, I am trying to get all the titles from
I'm having an issue integrating flex with ruby on rails. I get this error:
this is probably a simple mis configuration problem but I am having an issue
I am having an issue while accessing single database instance using multiple/distributed Hibernate SessionFactories
I'm having an issue with multiple classes assigned to one element and IE (9
I'm using Symfony 1.4 and having an issue using multiple form validators. For part
I am having an issue with creating queries with javax.persistence.criteria.CriteriaBuilder. I am using EclipseLink

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.