Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27333

Transferring ListView Checked Items to Text box taking too long

$
0
0
Hey guys, I have a list view that takes values from an analog sensor hooked up to an arduino board. The sensor reads values for a while then I need to transfer them to a text box, or string, or stream reader, etc. Just something that I can format so that one listview item ends up on one line in a text file with no line feed after the last value in the file and no delimiter.

I have it working but the problem is, on occasion there can be as many as 50,000 items in the list view which can take up to 15-20mins to transfer. This is unacceptable. I have tried several methods to quicken up the process. Here is the current code that produces the fastest result:

Code:

Dim cItems As ListView.CheckedListViewItemCollection = Main.listview.CheckedItems
        Dim ccount As Integer = cItems.Count

        ProgressBar1.Maximum = ccount
        ProgressBar1.Value = 1

        Dim num As New Integer
        num = 0
        datastring = Main.listview.CheckedItems(num).Text

        num = num + 1

        If ccount > 1 Then

            Do While num < Main.listview.CheckedItems.Count

                datastring = datastring + Environment.NewLine

                datastring = datastring + Main.listview.CheckedItems(num).Text
                previewtextbox.Text = datastring
                ProgressBar1.Value = ProgressBar1.Value + 1
                num = num + 1
            Loop

        Else

            previewtextbox.Text = datastring
            ProgressBar1.Value = ProgressBar1.Maximum

        End If

here is code that works, but gets slower and slower, and basically comes to a crawl, make take over an hour to do the transfer.

Code:

        Dim i As Integer

        ProgressBar1.Maximum = Main.listview.CheckedItems.Count
        ProgressBar1.Value = 1

        For i = 0 To Main.listview.CheckedItems.Count - 1

            textbox.AppendText(Main.listview.CheckedItems(i).Text + vbCrLf)
            ProgressBar1.PerformStep()
        Next


Is the answer that it is just a large amount of data and I need to suck it up? I am just thinking that the computer should be able to append text at the speed of light and it should only take a few seconds. When I watch the task manager the software isn't eating up tons of memory. In fact it stays somewhere around 25000k. Maybe it doesn't show up there? I'm not the world's genius when it comes to memory management, so maybe that is the problem. Thanks for any pointers.

Viewing all articles
Browse latest Browse all 27333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>