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

所属分类: 网络编程 / ASP编程 阅读数: 1640
收藏 0 赞 0 分享
在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>
更多精彩内容其他人还在看

IIS访问ASP页面时报错The requested resource is in use.的解决办法

IIS访问ASP页面时报错The requested resource is in use.的解决办法
收藏 0 赞 0 分享

错误类型:Provider (0x80004005)未指定的错误 的一个处理方法

一般情况下asp可以正常运行,但只要连接数据库就提示,Microsoft JET Database Engine 错误'80004005'
收藏 0 赞 0 分享

关于“未指定的错误”的问题 的比较正解的解决方法

关于“未指定的错误”的问题 的比较正解的解决方法
收藏 0 赞 0 分享

关于asp+access的安全问题分析

关于asp+access的安全问题分析
收藏 0 赞 0 分享

把RS.GetRows看得更清楚

把RS.GetRows看得更清楚
收藏 0 赞 0 分享

ASP面向对象编程探讨及比较

ASP面向对象编程探讨及比较
收藏 0 赞 0 分享

ASP错误处理

ASP错误处理
收藏 0 赞 0 分享

web文件管理器的后续开发

web文件管理器的后续开发
收藏 0 赞 0 分享

上一篇,下一篇过程代码

上一篇,下一篇过程代码
收藏 0 赞 0 分享

一小偷类!!有兴趣的可以看看

一小偷类!!有兴趣的可以看看
收藏 0 赞 0 分享
查看更多