I have problem with get data from vbscript in C# console application. I just write below code:
int[] i = new int[3] { 1, 2, 3 };
string msg = "";
object[] myParam = { msg , i};
MSScriptControl.ScriptControlClass sc = new MSScriptControl.ScriptControlClass();
sc.Language = "VBScript";
sc.AddCode("Sub Test(ByRef msg, ByRef aryI)" + Environment.NewLine +
" msg = \"234\"" + Environment.NewLine +
"End Sub");
sc.Run("Test", ref myParam);
I want to get msg modified string after call Run method, but it does not work anymore(not any change)
Could you please help to me ?
Thanks in advance
You will have to use Eval function or something similar that will return you the value back to you.
I dont know which one of above will work correcly but there will be something similar.
You are passing a variable to Script, in instance of Script only, the variable is used as Reference, but when C# passes the variable in sc.Run method it passes it as only value, not reference.
There is no way you can retrive value back which is ByRef in script.
Alternative way is to pass entire object.
Making class ComVisible, can let you access and change the properties through vbscript.