K
Ken Dahlberg
I've encountered a need to build a Class module that has a couple of
Types as members. So first the Type is defined in a standard module,
thus:
Public Type FitParms
XVar as String
YVar as String
Formula as String
Par(6) as Double
End Type
Then, in a Class module called PcGroup there are these statements:
Private jprms as FitParms
Public Property Get JParms() As FitParms
JParms = jprms
End Property
Public Property Let JParms(RHS As FitParms)
jprms = RHS
End Property
Now here's the "problem": the Let doesn't work the way I would like it
to. If gp is an instance of the PcGroup class, the Get works just as
expected: the statement
Private JFormula as String
JFormula = gp.JParms.Formula
assigns the appropriate value from the jprms Type to the local
variable JFormula. But if I try to do it the other way:
gp.JParms.Formula = JFormula
this again invokes the Property Get module, not the Let, and nothing
is assigned to the Formula field in jprms. The only way I can use the
Let is by defining a local FitParm variable and then assigning the
whole thing, like this:
Private fp as FitParm
fp = gp.JParms
fp.Formula = JFormula
gp.JParms = fp
Then the Let module is invoked and the assignment is made.
Am I missing something here? Is this really the way this works, or is
there some way make the Let to work the way I want it to? VBA doesn't
allow me to declare the Type as a Public member of the Class, so I
can't bypass the Get/Let construction.
Thanks,
Ken Dahlberg
Types as members. So first the Type is defined in a standard module,
thus:
Public Type FitParms
XVar as String
YVar as String
Formula as String
Par(6) as Double
End Type
Then, in a Class module called PcGroup there are these statements:
Private jprms as FitParms
Public Property Get JParms() As FitParms
JParms = jprms
End Property
Public Property Let JParms(RHS As FitParms)
jprms = RHS
End Property
Now here's the "problem": the Let doesn't work the way I would like it
to. If gp is an instance of the PcGroup class, the Get works just as
expected: the statement
Private JFormula as String
JFormula = gp.JParms.Formula
assigns the appropriate value from the jprms Type to the local
variable JFormula. But if I try to do it the other way:
gp.JParms.Formula = JFormula
this again invokes the Property Get module, not the Let, and nothing
is assigned to the Formula field in jprms. The only way I can use the
Let is by defining a local FitParm variable and then assigning the
whole thing, like this:
Private fp as FitParm
fp = gp.JParms
fp.Formula = JFormula
gp.JParms = fp
Then the Let module is invoked and the assignment is made.
Am I missing something here? Is this really the way this works, or is
there some way make the Let to work the way I want it to? VBA doesn't
allow me to declare the Type as a Public member of the Class, so I
can't bypass the Get/Let construction.
Thanks,
Ken Dahlberg