I have tried both of these to sum a listbox's entries
Code:Dim number As Integer = Me.lstBracingLengths.Items.Count - 1
Dim y As Integer
Dim totall As Integer
For y = 0 To number
totall = totall + Convert.ToInt16(Me.lstBracingLengths.Items.Item(y))
Next y
Me.txtBracingTotals.Text = Convert.ToString(totall)
Both work but they round the values up for some reason i cannot see.Code:Dim totall As Integer
For Each item As Integer In lstBracingLengths.Items
totall += item
Next
txtBracingTotals.Text = totall
see picture
http://img211.imageshack.us/img211/2282/image2cx0.jpg
I am using a round up formula before the entries are placed in the listbox but i cannot see that causing it
regardsCode:Dim wl As Double = Me.txtWallLength.Text
Dim wh As Double = Me.cmbWallHeight.Text
Dim sqr1 As Double = wl * wl
Dim sqr2 As Double = wh * wh
Dim Total As Double = sqr1 + sqr2
Dim sqrTotal As Double = Math.Sqrt(Total)
'populates listbox with bracing lengths
Me.lstBracingLengths.Items.Add(Math.Round(sqrTotal, 3))
toe
