Is it possible to set a class member to be another class member?

M

Michael

I have what I hope is an easy question: Is it possible to set a class
member to be another class member?

Let me explain, I have two defined classes in excel,

clsSomeFucntion contains 4 members, 3 which are parameters (A, B, C)
and 1 which is an output function (Total):

clsSolver contains 6 members, 5 which are parameters (Target,
MinPrecision, detlax, IntialGuess and ChangeVariable), and 1 which is
an output function (SolverOut).

From a module, I have set all of the parameters in both class modules.
I need to set clsSover.ChangeVariable to be one of the three
clsSomeFunction members (parameters A,B,C) based on which one the user
wants to use as a solver variable.

That is to say, I want clsSover.ChangeVariable not to contain the
value of clsSomeFucntion.a, clsSomeFucntion.b, or clsSomeFucntion.c,
but to actually set it to be either clsSomeFucntion.a,
clsSomeFucntion.b, or clsSomeFucntion.c, so I can change it to iterate
a solution in clsSolver.solverOut. (clsSomeFucntion.total is the
output I am solving for).

I'm having trouble finding variable definitions in both the calling
module and the class module that let me do this.

Any suggestions?
 
B

Bruce Lindsay

Since you can't inherit in objects you have to look at it differently. Have
the one class create an instance that has a collection item for this other
class object. At least I gather you are trying to associate one class with
another.
 
O

onedaywhen

I think you need a third class, say clsParameter. The clsSomeFunction
parameters A,B,C would be properties of type clsParameter and
clsSomeFunction would internally hold three instances of the
clsParameter class. clsSover.ChangeVariable would also be of type
clsParameter but would hold a reference/pointer to one of the A,B,C
objects.

If you require more details, post the code you have so far.
 
M

Michael

I think you need a third class, say clsParameter. The clsSomeFunction
parameters A,B,C would be properties of type clsParameter and
clsSomeFunction would internally hold three instances of the
clsParameter class. clsSover.ChangeVariable would also be of type
clsParameter but would hold a reference/pointer to one of the A,B,C
objects.

Thanks for the lead, adding a third class works great. I was too
fixated on only using the two classes.
If you require more details, post the code you have so far.

The code is quite extensive, but does work, I was just trying to
simplify the code by putting things in classes to avoid repetative
coding (you can download the program at wwww.easy-well.com). Thanks
again for the help ~Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top