VBS:Arrays
Simple programs on sending Array to Function
Example 1 :
'----------"a" is an array
'----------notice the way I'm sending it to the function
'----------notice how array is received at the function definition
'Moral of the story ,
'-------you can use paranthesis at function header in the function definition
'-------you can use paranthesis at function header in the function definition
'***************************************
a=array(4,23,1,2)
a=array(4,23,1,2)
res=fn(a)
msgbox res
function fn(x()) 'function fn(x)
fn=ubound(x)
fn=ubound(x)
end function
Example 2 :
dim a(4)
a(0)=1
a(1)=2
res= fn(a) 'fn call
msgbox res
a(0)=1
a(1)=2
res= fn(a) 'fn call
msgbox res
function fn(a()) 'fn definition
for i=0 to ubound(a)
res=res&a(i)&vbnewline
NEXT
fn=res
res=res&a(i)&vbnewline
NEXT
fn=res
end function
No comments:
Post a Comment