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 :(
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
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
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
"'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"
 
Top Bottom