在VBScript中实现-函数/方法名作为参数传入另一个函数
2007-08-21 00:00
639 查看
在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>
<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>
相关文章推荐
- 在VBScript中实现-函数/方法名作为参数传入另一个函数
- 使用java模拟scala函数式编程将函数作为参数传入方法中
- 方法名称作为参数传入函数中
- js实现调用方法(函数)时可动态传入不同参数个数、模拟实现方法(函数)重载
- C++.net 定义类 将类对象作为函数参数传入另一个类 出现错误
- 编写一个排序函数,实现数字排序。排序方法由客户函数实现,函数参数个数为两个,两个参数的关系作为排序后的元素间的关系。
- Python中将函数作为另一个函数的参数传入并调用
- js 把函数作为参数传递给另一个方法
- 用va_start() va_end()函数解决不定参数问题(即,fun(...)实现方法)
- spring mvc:实现给Controller函数传入map参数
- oracle Array类型作为参数传入函数(存储过程) 大字符串参数解决方案
- C#.NET常见问题(FAQ)-如何把函数名作为参数传递给另一个函数
- char *作为函数参数来实现传递
- 如何把多维数组传入函数做为参数之几个方法
- Python实现调用另一个路径下py文件中的函数方法总结
- C++中的Thunk技术 / 非静态类成员函数作为回调函数 的实现方法
- 关于将函数的地址作为参数传递给另一个函数调用
- this指针作为函数隐含参数传递的方法
- js匿名函数作为函数参数 (返回值作为另一个函数的参数)
- JavaScript中函数作为另一个函数的参数的时候它存在于哪个作用域