Running "String" of Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm wanting to run code that is generated as a string. For example, I've got
a class module called clsRecon with a property called "Name".

If I write the following code;

Dim aRecon as New clsRecon
aRecon.Name = "Bill"
debug.print aRecon.Name

then out prints Bill to the immediate window. What if I've passed string
variables so that Ive got the following

Dim aRecon as New clsRecon
Dim sType as String, sProperty as String
aRecon.Name = "Bill"
sType = "aRecon"
sProperty = "Name"

debug.print sType & "." & sProperty

of course... I'll just get "aRecon.Name"

how can I use the strings to get "Bill" instead.

Thanks,
Ryan
 
Yea... but I want to generate the command aRecon.Name using strings passed to
a function. My problem is whether there's a way (like with application.run
for macros) to run a string as code.

Thanks,
Ryan
 
perhaps you need this one:
just guessing:

Function nameof() as string
nameof = aRecon.Name
end function
 
Hokievandal said:
Yea... but I want to generate the command aRecon.Name using strings passed
to
a function. My problem is whether there's a way (like with
application.run
for macros) to run a string as code.
Dim x As New Class1
x.name = "Owain"
Debug.Print CallByName(x, "name", VbGet)

HTH

Rob
 

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

Back
Top