Avatar of Jason
Jason
Flag for Australia asked on

vb.net recording variation of change in listview

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

Visual Basic.NET.NET Programming

Avatar of undefined
Last Comment
funwithdotnet

8/22/2022 - Mon
funwithdotnet

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

ASKER
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
ASKER CERTIFIED SOLUTION
funwithdotnet

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck