Executing a line of code defined in a string

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

Guest

Need some help executing a line of code contained within a string variable.
Anyone know if this is possible?
 
Bob V. said:
Need some help executing a line of code contained within a string variable.
Anyone know if this is possible?

Look into the Microsoft Script Control 1.0
 
Rob Oldfield said:
Look at the InsertLines method.


Never used this, but it looks like the lines inserted become permanent code in
the module in which it is inserted..

I suggested the Script control because of its' flexibility.. but the OP has a
couple of options at least.
 
MikeB said:
Never used this, but it looks like the lines inserted become permanent code in
the module in which it is inserted..

I suggested the Script control because of its' flexibility.. but the OP has a
couple of options at least.

True. I've never needed to use it in anger either but there's always the
option of using the DeleteLines method as well if the original version of
the code needs to be kept clean. As you say... two options are better than
one.
 
dbaseIII, FoxPro etc. had what is called macro substitution, and in fact
could execute commands contained inside of a string.

Having done a very serous stint in FoxPro (1992 - dos version), I can attest
as to how useful this "macro" substitution feature is.

However, I done a ZILLION projects in ms-access and HAVE NEVER EVER EVER
missed that feature.

Since I NEVER EVER missed the feature, then I might want to ask why, or what
you are trying to accomplish. The fact that I don't miss the ability to
execute "user" code, *usually* means there is alternative to what it is you
re trying to accomplish.

Most of the time, using a dynamic collection, or the fact that you can stuff
a field name into a string var, and use that string to reference the data
does eliminate the need to have run-time execution of code.

Note that you can execute a expression, which can include most VB functions.
Check out the Eval() feature in help. However, you might want to explain a
bit as to what you are actually trying to do here, as I always found
reasonable workarounds to this problem.
 
Back
Top