Skip to content

ClearScript execution of VBS code does not support ByRef parameter passing #511

Description

@Rison-Hub

VBS CODE:
Option Explicit
Sub Main
dim reftest
reftest=0
zp.testRef 5,reftest
zp.print reftest

End Sub
Main
VB.NET CODE:
Public Class VBClass
Public Sub Print(ByVal OutStr As Object, ByVal Optional iShow As Integer = 1)
Console.WriteLine("OutStr: " & OutStr & "!")
End Sub

Public Sub testRef(ByVal OutStr As Integer, Optional ByRef iShow As Integer= 0)
    iShow = iShow + OutStr
    Console.WriteLine("testRef: " & iShow & "!")
End Sub

End Class

C# Code:
private void button10_Click(object sender, EventArgs e)
{
var VBscript = new VBClass();
using (var engine = new VBScriptEngine())
{
engine.AddHostObject("zp", VBscript);
var scriptCode = File.ReadAllText("D:/Script/abc.vbs");
engine.Execute(scriptCode);

        }

    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions