Skip to content

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

@Rison-Hub

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);

        }

    }

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions