call sub or function with arguments of arrays 
Author Message
 call sub or function with arguments of arrays

I have a function with two array arguments and return an array arguments
of the sum of the two. How can I define and invoke this function?

Thanks,

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sat, 05 Apr 2003 03:00:00 GMT  
 call sub or function with arguments of arrays

HI,

In VBA6:

Public Function AplusB (A( ) As Variant, B( ) As Variant) As Variant( )

    Debug.Assert LBound(A) = LBound(B)
Dim n As Long
    n=LBound(A)
    Debug.Assert UBound(A)=UBound(B)
Dim m As Long
    m=UBound(A)

Dim t( ) As Variant
    Redim t(n to m) as Variant

Dim i As long
    For i = n to m
        t(i)=a(i)+b(i)
    Next i

    AplusB = t        ' a simple = here

End Function

Quote:

> I have a function with two array arguments and return an array arguments
> of the sum of the two. How can I define and invoke this function?

> Thanks,

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sun, 06 Apr 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Calling function or sub with variable array or string names

2. Passing Functions or Procedures as arguments in Function or Procedure calls

3. Receiving Compile Error (Sub or Function not defined) while calling sub from shared module

4. Problem Sub with array arguments

5. Finding called Subs and Functions (call stack)

6. Passing array as argument to a sub

7. Call sub with arguments (Variable integer)

8. Call sub arguments

9. Call sub with arguments from .onaction (command bar button)

10. Argument unchanged after call to Sub that takes 1 ByRef parameter


 
Powered by phpBB® Forum Software © phpBB Group