HI I wonder if anyone will be kind enought to look at the code below and help remedy it. I am grateful to contributors from this site for even getting this far with my aim. The code attempts to do the following, to look at the first element in an array, if it is 1 it then looks at elements 13-16 and identifies the highest value, using a forecolor of BLue,it then puts that value in the first column of a listview and in an adjacent column puts the value of the array stored in element 7. If however the value at element 0 is nought then, using a forecolor or RED elements 19-22 are searched to find the lowest value. This value is then put in the first column and in an adjacent column the value in element 7 is put.
Trouble is it dont work that way. I wonder if anyone could help. Many thanks.
Public Sub listboxplayer1winodds(ByVal parray, ByVal numbofgames)
Dim win = System.Drawing.Color.DarkBlue
Dim lose = System.Drawing.Color.DarkRed
Dim odds = ""
Dim cards = ""
Form1.ListOddsP1.Items.Clear()
Form1.ListOddsP1.Columns.Add("Odds", -2, HorizontalAlignment.Left)
Form1.ListOddsP1.Columns.Add("Cards", -2, HorizontalAlignment.Left)
Dim winlvi As New ListViewItem
Dim loselvi As New ListViewItem
For k = numbofgames To 1 Step -1
If parray(k, 0) = 1 Then
Form1.ListOddsP1.ForeColor = win
odds = parray(k, 12)
cards = parray(k, 7)
For l = 13 To 16
If parray(k, l) > odds Then
odds = parray(k, l)
cards = parray(k, 7)
End If
Next l
Form1.ListOddsP1.ForeColor = win
winlvi.Text = odds
Form1.ListOddsP1.Items.Add(winlvi)
winlvi.SubItems.Add(cards)
Form1.ListOddsP1.ForeColor = win
Else
Form1.ListOddsP1.ForeColor = lose
odds = parray(k, 18)
cards = parray(k, 7)
For l = 19 To 22
If parray(k, l) > 0 And parray(k, l) < odds Then
odds = parray(k, l)
cards = parray(k, 7)
End If
Next l
Form1.ListOddsP1.ForeColor = lose
loselvi.Text = odds.ToString
Form1.ListOddsP1.Items.Add(loselvi)
loselvi.SubItems.Add(cards)
Form1.ListOddsP1.ForeColor = lose
End If
Next k
End Sub
Thanks for all and any help.