View Single Post
Old Feb 10th, 2005, 5:43 PM   #1
Aenimalius
Newbie
 
Aenimalius's Avatar
 
Join Date: Feb 2005
Posts: 3
Rep Power: 0 Aenimalius is on a distinguished road
Question Passing a control array to a function: Is it possible?

Hello everyone,

I'm working on a program that involves adding alot of numbers that are in textbox arrays and popping the sum out into a list box. What I'd like to do is write a function that runs through any array that I give it, adds the numbers and sends back the sum, but I can't figure out how to make the function accept the array.

Is it possible to send a control array to a function? If so, what's the proper syntax to do so? What I'm trying to do is something like this:

Public Function addArray (arrayOfNumbers As ????) As Integer

Dim sum as Integer

For i = 0 to arrayOfNumbers.UBound
     sum = sum + arrayOfNumbers(i)
Next

addArray = sum

End Function

I can't think of a better way to do this, because I'd rather not have 8 or 9 separate pieces of code that do the same thing to different arrays.

Peace.
__________________
Shameless Plug
Aenimalius is offline   Reply With Quote