VBS回调C# out用法
先来说下function和sub的区别: function称为函数,有返回值; 2、加call 形如“call sub_name (s1,s2)” 注:不需要返回值的用sub;需要返回值的用function,调用时去掉括号 |
以上解释:http://hi.baidu.com/wpbpan_bo/blog/item/fee7d8f354122657342acce1.html
VBS调用过程(Sub)时不能使用括号,若要加括号,需在方法前添加call关键字
C#code
using System; using System.Runtime.InteropServices; namespace MultiReturn_Class { [ComVisible(true)] public class Arithmetic { [ComVisible(true)] public void computing(double a, double b, out double c, out double d) { c = a + b; d = a - b; } } }
VBS code
dim myObj Set myObj = CreateObject("MultiReturn_Class.Arithmetic") myObj.computing(3,1,c,d) msgbox(c) msgbox(d)
Error
修改后的VBS code
dim myObj Set myObj = CreateObject("MultiReturn_Class.Arithmetic") call myObj.computing(3,1,c,d) myObj.computing 3,1,c,d msgbox(c) msgbox(d)