Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Problem dealing with arrays in VBScript

$
0
0
Hi,
I have following simple code. It works fine with MSScriptControl, but using VBScriptEngine it doesen't work:
    private void btnExecuteScript_Click(object sender, EventArgs e)
    {
        try
        {
            using (ScriptEngine engine = new VBScriptEngine())
            {
                object[] array = new object[] { 1, 2, 3 };
                engine.AddHostObject("arr", array);
                var value = (string)engine.Evaluate("arr(1) = 1");  
                MessageBox.Show(value.ToString());
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
Error message is: "Object does not support the requested invocation operation"

I'm new to clearscript. What i#m doing wrong?

Best regards
nbgedo

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images