View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Call the property of a class using a variable

When I began learning about classes, I attempted a sudoku puzzle. I figured
it offered opportunities to learn custom classes, events, and parent child
relationships. But I got sidetracked and never finished it <g. I've never
really found a lot of practical uses for custom classes in my work (or I'm
not using enough imagination), so my interest is mostly academic at this
point.

"Bob Phillips" wrote:

You are absolutely right, on both counts. I was/am working on it, and I got
sidetracked. The hardest part is getting a meaningful case to build a class
upon. Although I use them extensively, I need to find a custom object that
will ring a bell with the target audience. Most people use the ubiquitous
person class, which I think falls far short of the mark.

But I must admit that I had not intended to introduce CallByName within that
paper, I never use it, and I don't see much use for it personally.

--
__________________________________
HTH

Bob

"JMB" wrote in message
...
At one time, he was working on a paper regarding the use of class modules.
I
think he got sidetracked or was just teasing me <g

"Jim Thomlinson" wrote:

Well that's a new one for me to look into... I don't do classes that
often,
but that could be handy. General interest question. Do you actually know
everything or does it just appear that way to the rest of us... ;-)

To the OP... here is a resource on CallByName
http://msdn.microsoft.com/en-us/libr...x6(VS.80).aspx
--
HTH...

Jim Thomlinson


"Bob Phillips" wrote:

Function Change_Value(strProperty As String, iValue As Integer)
Dim objClass As MyClass

Set objClass = New MyClass

CallByName objClass, strProperty, VbLet, iValue

End Function


--
__________________________________
HTH

Bob

"Rob Wills" wrote in message
...
I'm sure this is possible.

I have written a class module which contains a number of properties.

I wish to change the value of one of the properties, however I want
to
dynamically identify the property that I'm changing

For example: if my class has integer properties of X and Y I wish to
be
able
to do somthing similar to below

========================================
Function Change_Value(strProperty as String, iValue as Integer)
Dim objClass As myClass

Set objClass = New myClass

objclass(strproperty) = iValue

End Function
=========================================

Thanks in Advance
Rob