Solved

vb.net recording variation of change in listview

Posted on 2016-07-30
3
42 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now