This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / In VBScript, can I call Sub in an array? How? -- Urgently need helpFor example, I have several Subs such as
Sub MsoffXP
.......
End Sub
Sub lotus123
......
End Sub
Sub Notes
...
End Sub
I want to define an array to call these Subs
Array[1] --> Msoffxp
Array[2] -->Lotus123
Array[3] --> Notes
But in VBScript, there's no Call command, how can I call sub using the variable?
Thanks for your help!
-meizi(梅子);
2002-4-24
{356}
(#478462@0)
-
there's no Call command---------WRONG
-nice2002(nice2002);
2002-4-24
(#478482@0)
-
Thanks for your reply. ..... But how to resolve my following problem? thanksI have several Subs such as
Sub MsoffXP (parameter1)
.......
End Sub
Sub lotus123 (parameter2)
......
End Sub
Sub Notes (parameter3)
...
End Sub
I want to define an array to call these Subs
Array[1] --> Msoffxp
Array[2] -->Lotus123
Array[3] --> Notes
how can I call Subs?
Thanks for your help!
-meizi(梅子);
2002-4-24
{330}
(#478500@0)
-
herefor x=0 to (array.length-1)
select case x
case 0
call ...
case 1
call...
end select
Next
-nice2002(nice2002);
2002-4-24
{95}
(#478510@0)
-
俺帮你搞定,请俺喝啤酒吗?一瓶aFunc = array("Func1","Func2")
parm="hello"
sFunc = aFunc(0) + "(""" & parm & """)"
call eval(sFunc)
function Func1(sParm)
'// code for this function goes here.
end function
-rootbear(啤酒晕头);
2002-4-24
{199}
(#478975@0)
-
There is a "Call" function in VBScript, but the function name could not be a variable.
-ddmm(路人甲);
2002-4-24
{529}
(#478491@0)
-
能改成用JSCRIPT/JAVASCRIPT吗? 我肯定VBSCRIPT是可以实现的, 但语法忘了. JSCRIPT见内, IE运行通过var s=new Array
function A(){alert('abc')}
function B(){}
function C(){}
s[0]=A
s[1]=B
s[2]=C
i=0
s[i]();
-zhihaoxx(Dilbert*XP);
2002-4-24
{121}
(#478518@0)
-
Thank you all. But I need to use VBScript. Actually, I can use another way to call this functions one by one. but .......
-meizi(梅子);
2002-4-24
{5672}
(#478542@0)
-
VB solution:dim arry
arry=Array()
sub A()
msgbox("hello A")
end sub
sub B()
msgbox("hello B")
end sub
set arry(0)=GetRef("A")
i=0
arry(i)()
-zhihaoxx(Dilbert*XP);
2002-4-24
{158}
(#478598@0)