页面导航: 首页网络编程ASP编程应用技巧 → 正文内容 在VBScript中实现-函数/方法名作为参数传入另一个函数

在VBScript中实现-函数/方法名作为参数传入另一个函数

发布:dxy 字体:[增加 减小] 类型:转载
在JS中有这种用法,某个函数名可以当成参数的形式,传入到另外一个函数内部去,例如:
<script type="text/javascript">
<!--
function myFuncA(str,myFuncB){
 str = str + " 您好!";
 str = myFuncB(str);
 return str;
}
function myFuncB(str){
 str = str + "欢迎来到IECN.NET";
 return str;
}
alert(myFuncA("张三",myFuncB));
//-->
</script>
在VBScript有两种方式可以来实现,即用execute或GetRef 函数。
一、利用execute:
<script language=vbscript>
Function myFuncA(str,myFuncName)
 str = str & " 您好!"
 execute("str = " & myFuncName & "(str)")
 myFuncA = str
End Function
Function myFuncB(str)
 str = str + "欢迎来到IECN.NET"
 myFuncB = str
End Function
msgbox myFuncA("张三","myFuncB")
</script>
二、利用GetRef:
<script type="text/vbscript">
Function myFuncA(str,myB)
 str = str & " 您好!"
 str = myB(str)
 myFuncA = str
End Function
Function myFuncB(str)
 str = str + "欢迎来到IECN.NET"
 myFuncB = str
End Function
document.write(myFuncA("张三",GetRef("myFuncB")))
</script>
浏览次数:载入中... 打印本文关闭本文返回首页

文章评论

共有 位脚本之家网友发表了评论我来说两句

同 类 文 章
最 近 更 新
热 点 排 行