call back to C# function from within VBScript run with msscript.ocx -


i want use msscript.ocx call vbscript c#, , allow vbscript code call functions in c# program.

for example, in following vbscript code, clicktext custom c# function in same clsss using msscript.ocx run vbscript.

for i=0 i=4      clicktext("auto")  next 

the clicktext function shoud called 5 times.

is there way it?

this comvisible console application reference interop.msscriptcontrol:

// !! http://sandsprite.com/blogs/index.php?uid=11&pid=83  using system; using msscriptcontrol;  //class test has support idispatch addobject(). make assembly comvisible //via assemblyinfo.cs or [assembly: system.runtime.interopservices.comvisible(true)]  namespace mssctest {     public class cshelper {         public int increment(int y) { return ++y; }     }      class program {         public static msscriptcontrol.scriptcontrol sc = new scriptcontrol();         static void main(string[] args) {             sc.language = "vbscript";             sc.addobject("cshelper", new cshelper(), true);             sc.addcode(@" function inc(n)   inc = cshelper.increment(n) end function msgbox inc(4711), 0, 'with little friend cshelper' ".replace("'", "\""));             return;         }     } } 

pudding:

--------------------------- little friend cshelper --------------------------- 4712 --------------------------- ok    --------------------------- 

demonstrates how call method of c# object vbscript code added msscriptcontrol.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -