Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

vb.net recording variation of change in listview

Posted on 2016-07-30
3
49 Views
Last Modified: 2016-08-05
I am looking for assistance with code the displays the change in value of a column in a list view

example this column changes every 3 seconds.  It clears the listview and writes the new values
so the column values would need to be store before clearing the some comparing of stored value to new value

let say these are the start values
column 0    Column 1
1                   0
2                   0
4                   0
2                   0
3                   0
5                   0

after 3 second

column 0              Column 1
1 goes to 4           3
2 goes to 3           1
4 goes to 1           -3
2 goes to 5           3
3 goes to 1           -2
5 goes to 4           -1

the code i am working with is
#Region "RunnerPoolDristrabution"
    Private poollist As New ArrayList
    Public Sub RunnerDistrabution()
        Dim i As Decimal = 0
        Dim ipool As Decimal = 0
        Dim q As Decimal = 0
        Dim count As Integer = 0



        For Each item As ListViewItem In ListView7.Items

            i = (winpool - ipool) / CDec(item.SubItems(1).Text)
            item.SubItems(8).Text = (i + (0.2 * i)).ToString("N2")
            If poollist(count).ToString <> item.SubItems(8).Text Then
                poollist.    ((i + (0.2 * i)).ToString("N2"))
            End If
            ipool = ipool + i
            count += 1
        Next
        For Each item As ListViewItem In ListView7.Items
            q = CDec(item.SubItems(8).Text)
            item.SubItems(9).Text = (i + (0.2 * i) - CDec(q)).ToString("N2")
        Next


    End Sub

#End Region

Open in new window

0
Comment
Question by:Jason
  • 2
3 Comments
 
LVL 12

Expert Comment

by:funwithdotnet
ID: 41736705
Perhaps you could provide a larger context? Your example doesn't seem to match your code.

Why is the ListView being cleared? Why not just update the ListView every three seconds? That way you already have the old value stored and can do all the calculations and then update with the new values.
0
 

Author Comment

by:Jason
ID: 41737330
the program is a horse race industry program
the reason I used clear listview method was due to the scratchings.  

The code below is the code used.  I actually cycles through every second.
I am open for suggestions with anything that could make it more efficient.
Update would fix the display for the Var at the moment it flashes up for a second and goes due to the clear

The 2 images attached provide me the variance when it flashes up but doesn't remain due to the clearing

        Dim poollist As New ArrayList ' this saves the poollist before clearing
        Dim varlist As New ArrayList ' this saved the variance before clearing
        first = 0
        second = 0
        third = 0
        Div = 0

        Countdown()
        If finished = True Then
            Exit Sub
        End If
        Try
            'Log("Step1")
            If OddsDisplayActive = True Then

                For Each item As ListViewItem In ListView7.Items
                    If item.SubItems(8).Text <> "" Then
                        poollist.Add(item.SubItems(8).Text)
                        If item.SubItems(9).Text <> "" Then
                            varlist.Add(item.SubItems(9).Text)
                        End If
                    End If
                Next
                ClearListviews(3)
TryAgain:
                    tabUri = SelectedRace

                    If Uri.TryCreate(tabUri, UriKind.Absolute, apiUri) = True Then
                        result_post = SendRequest(apiUri)

                        Try
                           [subtitle]TabRace = serializer.Deserialize(Of TAB.Race)(result_post)[/subtitle] ' this is where race data is imported
                            'Log("step2")
                        Catch
                            UpdateToken()
                            Log("Token Change")
                            Thread.Sleep(100)
                            GoTo TryAgain
                        End Try
                        Dim decimal1 As Decimal = New Decimal(TabRace.pools(5).poolTotal.Value)
                        winpool = New Decimal(TabRace.pools(0).poolTotal.Value)
                        winpool = winpool - (0.145 * winpool)
                        SetRaceLabelText(Label125, "$" & winpool.ToString("0.00"), "Label125")
                        decimal1 = decimal1 - (0.21 * decimal1) 'This is where TAB Take removed fron pool
                        SetRaceLabelText(Label107, TabRace.pools(5).poolStatusCode, "Label107")
                        betstatus = TabRace.pools(5).poolStatusCode
                        SetRaceLabelText(lblTriPool, "$" & decimal1.ToString("0.00"), "lblTriPool")
                        TriPool = decimal1.ToString("0.00")
                        SetRaceLabelText(Label30, TabRace.raceStatus, "Label30")

                        For Each runner As TAB.runners In TabRace.runners
                            Dim DisplayOdds As Double = runner.parimutuel.returnWin
                            If DisplayOdds <> 0 Then
                                Dim NewRunner As ListViewItem = ListView7.Items.Add(runner.runnerNumber.ToString)
                                NewRunner.SubItems.Add(DisplayOdds.ToString("0.00"))
                                NewRunner.SubItems.Add("")
                                NewRunner.SubItems.Add("")
                                NewRunner.SubItems.Add("")
                                NewRunner.SubItems.Add(False) ' check1
                                NewRunner.SubItems.Add(False) ' check2
                                NewRunner.SubItems.Add(False) ' check3
                                NewRunner.SubItems.Add("")
                                NewRunner.SubItems.Add("")
                            End If
                        Next
                        If ListView7.Items.Count <> lv7count Then
                            ListView7.Controls.Clear()
                            addboxes = True
                            lv7count = ListView7.Items.Count
                        End If
                        If addboxes Then
                            AddChkBoxes(ListView7.Items.Count)
                        End If
                        'Log("step3")
                        If TabRace.dividends IsNot Nothing Then
                            For i = 0 To TabRace.dividends.Count - 1
                                If TabRace.dividends(i).wageringProduct = "Trifecta" Then
                                    first = TabRace.dividends(i).poolDividends(0).selections(0)
                                    second = TabRace.dividends(i).poolDividends(0).selections(1)
                                    third = TabRace.dividends(i).poolDividends(0).selections(2)
                                    Div = TabRace.dividends(i).poolDividends(0).amount
                                End If
                            Next
                        End If
                    End If
                    'Log("step3a")
                End If
                'Log("step4")
                Dim num1 As Integer = 1
            ListView7.ListViewItemSorter = New ListViewComparer(num1, System.Windows.Forms.SortOrder.Ascending)
            ProcessMoneyGap()
            CheckBoxState()
            If ListView7.Items.Count <> 0 Then
                getRules()
                PercPool()
                RunnerDistrabution(poollist, varlist)
                If Button1.Text = "Automatic" Then
                    chkBetSystem()
                ElseIf Button1.Text = "Manual" Then
                End If
                If Not lv3Focus Then
                    ComboCalcs()
                End If
                getRaceResults(first, second, third, Div)
            End If
            ChkRaceStatus()
            'Log("step5")
        Catch ex As Exception
            Log(ex.ToString)
        End Try
        myTimer_Main.Dispose()
        StartMain(True)
    End Sub

Open in new window

With Var when flashes upWhen there is no change in odds
0
 
LVL 12

Accepted Solution

by:
funwithdotnet earned 500 total points
ID: 41738369
If a clear is necessary, perhaps you could just copy the current listview.Items to a temp variable, clear the listview, get the the new list, compare to the temp variable and update the list as necessary. Something like that?
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question