Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# vb.net recording variation of change in listview

Posted on 2016-07-30
Medium Priority
64 Views
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
``````
0
Question by:Jason
[X]
###### 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
• 2

LVL 12

Expert Comment

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

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
If item.SubItems(9).Text <> "" Then
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")
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)
End If
Next
If ListView7.Items.Count <> lv7count Then
ListView7.Controls.Clear()
lv7count = ListView7.Items.Count
End If
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
``````
0

LVL 12

Accepted Solution

funwithdotnet earned 2000 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

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
###### Suggested Courses
Course of the Month11 days, 7 hours left to enroll