I have the following VBA code:
Option Explicit
Private a(2) as Double
Private b(2) as Double
Public Function Hello(X1 As Double, X2 As Double) As Double
a(1) = X1 + X2
a(2) = X1/X2
b(1) = X1
b(2) = X2^2
Hello = a(1)+a(2)+b(1)+b(2)
End Function
Within the function Hello I have defined a(1),a(2),b(1),b(2).
However, I want to make some function or sub-routine that accepts X1 and X2 as arguments and spits out the values for a(1),a(2),b(1),b(2). This is because I use the above definitions for a(1),a(2),b(1),b(2) in about 20 functions in my module and would like to avoid having to do the following in each function that I use thesis in:
a(1) = X1 + X2
a(2) = X1/X2
b(1) = X1
b(2) = X2^2
a(1),a(2),b(1),b(2)as stated above that I can call within the 20 functions that need those definitions. As far as functions go I only know how to make them output 1 value, I don't know how to get them to define multiple objects.I want some function or sub-routine that defines a(1),a(2),b(1),b(2) as stated aboveYou are not defining but assigning in the above code... There is a difference between the two.X1andX2are different so I can't just assign values to them outside of all 20 functions.a(1),a(2),b(1),b(2)You can simply use 1 function and then using conditional code, assign values to them.a()andb()and act upon them with the methods in the class. cpearson.com/excel/classes.aspx