2

I would like to know if something like this pseudo code:

myVar = "functionName"
call someObject.(myVar evaluation)

which would then be equivalent to:

call someObject.functionName

is possible in VB. I know this is done in some other languages using a GetProperty method.

Cole Tobin
  • 9,206
  • 15
  • 49
  • 74
Luis
  • 1,210
  • 2
  • 11
  • 24
  • See http://stackoverflow.com/questions/1744216/how-do-i-assign-a-value-to-a-property-where-the-property-name-is-supplied-at-runt/1744555#1744555 – jtolle Jun 01 '10 at 17:10

1 Answers1

1

You can try the CallByName method to accomplish this. There is also an Eval function in VB/VBA.

Here's the code for that in VB.Net:

CallByName(YourClassName, "variableName", CallType.SET, valueToSet)

You can even read property using it's string-name:

someVariable = CallByName(YourClassName, "variableName", CallType.GET)
Mia Clarke
  • 8,134
  • 3
  • 49
  • 62
Garett
  • 16,632
  • 5
  • 55
  • 63