My code is below - any assistance would be appreciated!!

``````'to count the number of items in the listbox
Dim curindex As Integer
Dim intCounter As Integer
For intCounter = 0 To UBound(strgrade)
Next
For curindex = 0 To UBound(strgrade)
Next
For curindex = 0 To UBound(strgrade)
Next
LblSum.Text = total
End Sub``````

## All 5 Replies

First of all, did you color the code yourself? If so, please don't. Using code tags properly will color it for you. it's [[B]code=vb[/B]] (no spaces) at the beginning, and at the end of the code [[B]/code[/B]]. Also, indenting your code would help a lot, too.

I can't figure out how your question and the code is related. You mention

When the user clicks the calculate button, I determine the total number of entries (listgrades.item.count); this value is returned correctly. I then try to copy the contents of the listbox into an array as I thought that would be the best way to determine the highest, lowest, and sum of all the grades.

Why are you defining strallgrades as a string if you want to find the lowest, highest, and sum? Wouldn't integers be more appropriate?

I would then use the sum/total to get an average.

Where is sum calculated? I expected to see a + somewhere in the code used to add the values together.

Update the code to add the grades together and see how that works. mIf it does, try calculating the average. If it doesn't, post again and we can tweak your attempt.

We also want to see how you are adding Items to Listbox, because if you don't have correct code then users can add empty items which might cause another error.

``````'use a list box and a form
'use the list box functin to add items to the list box
dim max, min,average,total as integer
'calculaindg maximum value
max=lstgrades.listindex(0)'i have set the max value to the first value in the list
for index as integer= 0 to lstgrades.listcount
else
endif
max=val(txtmax.text)
next index
'caculating minimum value
for index as integer= 0 to lstgrades.listcount
else
endif
min=val(txtmin.text)
next index
'calculating sum and average
dim index, total,sum as integer
dim average as single
next index
sum=val(txttotal.text)

if average<40 then
elseif average>=40 and<=60 then
elseif average>60 and <=80 then
elseif average>80 and<=100 then
else
endif
endif
endif
endif