loop for totalling

cbvandal
04-17-2003, 05:37 AM
I am trying to work out how to add up all the entries in a list view to provide a total, the entries are item prices, i believe I should be using a loop to add all the entires together but due to my lack of knowledge I have no idea how to this, can anyone help????? :confused:

Robse
04-17-2003, 05:56 AM
Maybe this (http://www.visualbasicforum.com/showthread.php?threadid=20641) can give you some ideas. (I searched for "listbox total" in this forum)

Machaira
04-17-2003, 05:57 AM
Try something like:

Private Sub Form_Load()

Dim iLp As Integer
Dim sngTotal As Single
Dim sngVal As Single

Randomize

For iLp = 1 To 10
sngVal = Format(100 * Rnd, "##0.00")
ListView1.ListItems.Add iLp, , sngVal
Next iLp

For iLp = 1 To ListView1.ListItems.Count
sngTotal = sngTotal + Val(ListView1.ListItems(iLp))
Next iLp

MsgBox sngTotal

End Sub

JetEngineCom
04-17-2003, 06:49 AM
if you don't have to use a list box, you could querry the database and provide the report in the format you want ... or querry and output to a form formatted like a list box

Machaira
04-17-2003, 10:26 AM
Umm, a database was never mentioned.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum