![]() |
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 IntegerI 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. |
Logically you should be able to do this:
Private Sub MyFunction(ByRef MyArray() as TextBox) however, VB in its strange way, actually doesn't hold control arrays on forms in the same way as arrays of variables. Similarly the ParamArray keyword won't work. Even if you did get it through, ubound() and lbound() don't work on control arrays, nor does the For Each syntax. The only way I can see of doing it is to pass the control array range to the routine (i.e. the upper and lower bounds). |
| All times are GMT -5. The time now is 2:01 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC