Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Get Property value of class instance by passing string property name
Does anyone know how to get the value of a property of an instance of
a class by passing the string as the name of the property? I have seen it somewhere before e.g. GetPropertyValueForClass(myClass,"PropertyName") Any help would be really appreciated Thanks Mark |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Get Property value of class instance by passing string property name
Hi Mark,
Are you thinking of CallByName, eg ' code in normal module Sub test() Dim cls As Class1 Set cls = New Class1 CallByName cls, "PropA", VbLet, 123 MsgBox CallByName(cls, "PropA", VbGet) End Sub ' code in Class1 Private mnID As Long Public Property Let PropA(ID As Long) mnID = ID End Property Public Property Get PropA() As Long PropA = mnID End Property Regards, Peter T wrote in message oups.com... Does anyone know how to get the value of a property of an instance of a class by passing the string as the name of the property? I have seen it somewhere before e.g. GetPropertyValueForClass(myClass,"PropertyName") Any help would be really appreciated Thanks Mark |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Get Property value of class instance by passing string property name
Use CallByName:
Dim Res As Variant Dim PropName As String Dim Obj As New Class1 ' some code to set up Obj PropName = "MyProperty" Res = CallByName(Obj, PropName, VbGet) -- Cordially, Chip Pearson Microsoft MVP - Excel, 10 Years Pearson Software Consulting www.cpearson.com (email on the web site) wrote in message oups.com... Does anyone know how to get the value of a property of an instance of a class by passing the string as the name of the property? I have seen it somewhere before e.g. GetPropertyValueForClass(myClass,"PropertyName") Any help would be really appreciated Thanks Mark |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Passing several parameters to OnAction property. | Excel Discussion (Misc queries) | |||
How to cycle through each of property and its value of Class? | Excel Worksheet Functions | |||
Property Let: assign return value of Double when passing String | Excel Discussion (Misc queries) | |||
Cannot set HorizontalAlignment Property of the Range Class | Excel Programming | |||
Using Property Let with a Type as member of a Class | Excel Programming |