Average'd Out

tk.unlimited

Active member
Joined
Apr 2, 2005
Messages
27
Programming Experience
1-3
I'm having trouble getting an average of marks from a listbox.. These are the following steps:
-Find out how many marks in the listbox - this is the limit for the loop

-Start a total variable with 0

-Using a FOR LOOP, loop though each mark in the marks listbox and add each mark to the total variable. The for loop will need to start from 0.

-You can access an item in hte listbox using the following line of code (Assuming iItemCounter is the counter being used by the FOR loop)

iMark = me.lstboxname.items(iitemcounter)

That is what im having trouble with... I know how to get the average from here.. Please Help :(
 
well to get the upperboundry of the loop use lstboxname.items.count - 1 such as

for intcounter = 0 to lstboxname.items.count - 1
'do stuff
next intcounter
 
"'Do stuff" means that you should have the program do whatever it is that needs to be done inside the loop

i think you want

VB.NET:
 for intcounter = 0 to lstboxname.items.count - 1
  iMark = me.lstboxname.items(iitemcounter)
 next intcounter

but i'm not sure what all you need done inside the loop so i kept it to a general "Do stuff"
 
Back
Top