R
rozner
Hi,
I am having some trouble with collections. I'm trying to pass a
collection to a function to do some work, but whenever I get a compile
error "argument not optional". Everything seems to look ok, I've tried
a lot of variations on this, here is my code:
Code:
--------------------
Dim results As New Collection
' code here to get results
Dim topResults As New Collection
' call get top results function
topResults = getTopResults(results) ' fails here
' top results function
Public Function getTopResults(ByRef list As Collection) As Collection
Dim maxByProgram As Collection
Dim topResults As Collection
maxByProgram = getMaxByProgram(list)
Dim i As Integer
For i = 0 To list.Count
Dim result As Score
Dim Program As String
result = list(i)
Program = Score.Program
Dim max As Integer
max = maxByProgram.Item(Program).Score
If Score.Score = max Then
topResults.Add result
End If
Next i
getTopResults = topResults
End Function
I am having some trouble with collections. I'm trying to pass a
collection to a function to do some work, but whenever I get a compile
error "argument not optional". Everything seems to look ok, I've tried
a lot of variations on this, here is my code:
Code:
--------------------
Dim results As New Collection
' code here to get results
Dim topResults As New Collection
' call get top results function
topResults = getTopResults(results) ' fails here
' top results function
Public Function getTopResults(ByRef list As Collection) As Collection
Dim maxByProgram As Collection
Dim topResults As Collection
maxByProgram = getMaxByProgram(list)
Dim i As Integer
For i = 0 To list.Count
Dim result As Score
Dim Program As String
result = list(i)
Program = Score.Program
Dim max As Integer
max = maxByProgram.Item(Program).Score
If Score.Score = max Then
topResults.Add result
End If
Next i
getTopResults = topResults
End Function