functions
dear all
I have two questions 1) How can I write a function that accepts multiple inputs (arguments) and return multiple values? The straightforward method accepts multiple values and returns a single value (that is the name of the function) 2) How can I write a function that accepts multiple arrays as input arguments and returns an array too. ex: if I have two arrays x , y how can I configure a function f(x,y) that return an array representing the pointwise multiplication of x,y i.e f(i)= x(i)* y(i) thanks in advance |
functions
Public Function MultArray(x, y)
Dim f() As Double ReDim f(LBound(x) To UBound(x)) For i = LBound(x) To UBound(x) f(i) = x(i) * y(i) Next MultArray = f End Function Sub tester4() Dim u As Variant Dim x As Variant, y As Variant x = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) y = Array(2, 4, 6, 8, 10, 12, 14, 16, 18, 20) u = MultArray(x, y) For i = LBound(u) To UBound(u) Debug.Print i, u(i) Next End Sub Would be one possibility -- Regards, Tom Ogilvy marwan hefnawy wrote in message ... dear all I have two questions 1) How can I write a function that accepts multiple inputs (arguments) and return multiple values? The straightforward method accepts multiple values and returns a single value (that is the name of the function) 2) How can I write a function that accepts multiple arrays as input arguments and returns an array too. ex: if I have two arrays x , y how can I configure a function f(x,y) that return an array representing the pointwise multiplication of x,y i.e f(i)= x(i)* y(i) thanks in advance |
All times are GMT +1. The time now is 02:55 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com