
Passing Arrays to Functions - Subscript Out of Range Problem
Quote:
> Hi,
> I m passing an array to a function in VBScript while doing Server side
> scripting.
> Codes are likewise -
> dim arr()
> dim len
> len = 5
> redim preserve arr(len)
> '*** a function " function test(byref arr() as string, length as integer)"
> prevails **
> '** Following call is made******************
> test arr(),len
> on executing these codes i m getting an Error Message as below -
> Microsoft VBScript runtime error '800a0009'
> Subscript out of range
> PLEASE GUIDE ME HOW TO GET OUT OF THIS PROBLEM
> thanx n regards to all of u
> Bhupendra
Since it is passed by reference, simply pass the Name of the variable to
the routine. That is, drop the parentheses ...
test arr,len
Besides that, you don't actually need to pass the length, as the Ubound
function can be used in the function to determine the upper bound
(length) of the array.
Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/