What am I doing wrong here?
Sub Main()
Dim patients() As String
\' Some code to populate the patients array, works fine
CalculateScores (patients) \' Arra
When you do this:
DoSomething (expression)
You're forcing expression
to be evaluated as a value, and passed ByVal
, regardless of whether the parameter explicitly says it's passed ByRef. While that has more or less no impact most of the time, it bites you in the rear end when you try to pass an array or an object reference.
Drop the parentheses.
DoSomething expression
Now, there are other problems with your code: You're passing an array of strings into a String
parameter; that can't work. Make the parameter an array or a Variant
, and I'd suggest marking the parameter explicitly as ByRef
, for clarity.