Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > loop for totalling


Reply
 
Thread Tools Display Modes
  #1  
Old 04-17-2003, 05:37 AM
cbvandal cbvandal is offline
Freshman
 
Join Date: Feb 2003
Posts: 34
Unhappy loop for totalling


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?????
Reply With Quote
  #2  
Old 04-17-2003, 05:56 AM
Robse's Avatar
Robse Robse is offline
Senior Contributor

* Expert *
 
Join Date: Sep 2002
Location: Karlsruhe, Germany
Posts: 1,319
Default

Maybe this can give you some ideas. (I searched for "listbox total" in this forum)
__________________
Posting Guidelines MSDN-VB API List Use [vb]...[/vb] tags for code!
Reply With Quote
  #3  
Old 04-17-2003, 05:57 AM
Machaira's Avatar
Machaira Machaira is offline
Jedi Coder

* Expert *
 
Join Date: Aug 2002
Location: Abingdon, MD
Posts: 3,438
Default

Try something like:
Code:
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
Reply With Quote
  #4  
Old 04-17-2003, 06:49 AM
JetEngineCom's Avatar
JetEngineCom JetEngineCom is offline
Freshman
 
Join Date: Apr 2003
Location: DeepSpace
Posts: 31
Default

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
__________________
what will happen when the black hole swallows the entire universe ... what?
Reply With Quote
  #5  
Old 04-17-2003, 10:26 AM
Machaira's Avatar
Machaira Machaira is offline
Jedi Coder

* Expert *
 
Join Date: Aug 2002
Location: Abingdon, MD
Posts: 3,438
Default

Umm, a database was never mentioned.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Standards and Practices loquin Tutors' Corner 10 07-28-2006 12:16 PM
Help .. I'm Stuck in a Loop Steven_Teo General 5 04-08-2003 03:48 AM
dx main loop Waxycat Miscellaneous Languages 3 02-25-2002 02:28 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->