I have to add a VBScript interface to our C# app and have completed this with ScriptControlClass
(MS Scripting Engine). However, I am not too familiar with VBS and can't find a solution to this:
If I define a class then decide to make a change to that class, when I run the code for the class a second time I get the error:
Name redefined
Example:
- Define a
Class
(ex:Class test .... End Class
) - "Compile" (from C# code, call
ScriptControlClass.AddCode(code_for_class)
) - Make a change to the class's code
- "Compile" again - get error here
How do I "undefine" the class before trying to compile?
Also, I am not asking about how toDim
or Redim
an object of that class. I want to modify the class code.
Script code is not "compiled", it is executed when you call
AddCode()
All of the code you add is known by the scriptcontrol until you do
Reset()
. Resetting makes the scriptcontrol remove all the code that has been added.So you'll first have to
Reset()
before you add the code for the same class again.