I use Script control to attach a function to aproject at runtime.

The first step is to add a Module by:
ScriptControl1.Modules.Add "Mod"
Then add a function to the module
ScriptControl1.Modules("Mod").AddCode "Function FName()......."

In the function I use some public variables defined in the project.
I run the function by:
ScriptControl1.Modules("Mod").Run(FName)

The function can be run successfully. The problem is the public variables are not recognied in the function. Anybody know this please advice how to solve this problem. Thanks a lot!