我正在尝试编写一个函数,该函数可以从具有2个参数的Function返回多个值.
例如:
function sample_function(arg1,arg2)
''#Some code.................
passenger = list1(0)
name1 = list1(1)
age1 = list1(2)
seatNumber = list1(3)
''#This is an Incomplete function...
end function sample_function
Run Code Online (Sandbox Code Playgroud)
这个名为sample_function的函数有两个名为arg1的参数arg2.当我打电话在我的驱动脚本像值= sample_function(2 Name_person)这个函数,这个函数应该返回我的乘客,姓名1,AGE-1,seatNumber值.
我怎样才能实现这一目标?
编辑(LB): QTP使用VBScript来指定的测试程序,所以我重新标记这VBScript中,VB因为该解决方案可能是在VBScript.
Nor*_*ame 23
一个简单的解决方案是返回一个数组:
function foo()
foo=array("Hello","World")
end function
x=foo()
MsgBox x(0)
MsgBox x(1)
Run Code Online (Sandbox Code Playgroud)
如果您碰巧经常使用同一批值,那么可能需要付费才能使其成为用户定义的类:
class User
public name
public seat
end class
function bar()
dim r
set r = new User
r.name="J.R.User"
r.seat="10"
set bar=r
end function
set x=bar()
MsgBox x.name
MsgBox x.seat
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
64397 次 |
| 最近记录: |