|
-
Apr 2nd, 2022, 03:20 AM
#1
Thread Starter
PowerPoster
[RESOLVED] Find the average value of a listbox
Hi there everyone. I am working on a math program to record students answers to a program. I am looking into getting the average value from a listbox of answers called AnswerList.
Basically, I am wondering how to add up the listbox items because they are all numbers, and then divide by the number of items in the listbox. Would anyone know how I can do that?
Thanks a lot!
-
Apr 2nd, 2022, 03:22 AM
#2
Thread Starter
PowerPoster
Re: Find the average value of a listbox
This code for example will add up the total sum of the items in the listbox.
VB Code:
Dim I As Integer
Dim tot As Integer
For I = 0 To AnswerList.ListCount - 1
tot = tot + Val(AnswerList.List(I))
Next
MsgBox tot
But after that, how would I divide by the number of items?
EdIT: Oh wait, would it just be MsgBox Val(tot / List1.ListCount)?
That seems to work on my end.
-
Apr 2nd, 2022, 05:46 AM
#3
Re: Find the average value of a listbox
Solved, then? Now, maybe you can figure out the mean, the median and even a Bell Curve!!!!
Oh, and make sure you don't dim your average variable as an integer.
Sam I am (as well as Confused at times).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|