This should be straightforward, but ...

What is the correct way to pass an array as a function argument in
VBScript?

For example, I have a call in an ASP:

<!-- #include file = ../../../functions/dbps.inc -->
Dim strPjCode
Dim intVal
Dim arrValue(50)
intVal = ProjectSort(strPjCode, arrValue())

The custom function is:

Function ProjectSort(strPjS, arrV())

ProjectSort = 0

etc.

The ASP generates the following error:

Microsoft VBScript runtime error '800a0009'

Subscript out of range

If I remove the () after the array in the ASP and Function I get a
different error:

Microsoft VBScript runtime error '800a01f4'

Variable is undefined: 'ProjectSort'


Any suggestions? Thanks.






*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Re: Using Array as Argument in Custom Function by Stan

Stan
Wed Jul 14 17:58:08 CDT 2004

Graham,

Here's an example based on a client-side HTML page, but it should be the
same in ASP:

Dim strPjCode
Dim intVal
Dim arrValue(50)
intVal = ProjectSort(strPjCode, arrValue)
document.write intVal

Function ProjectSort(strPjS, arrV)
for t = 0 to uBound(arrV)
j = j + t
next

ProjectSort = j
end function

Hope this helps,

Stan Scott
New York City

"Graham Copeland" <gcopeland@inetix.com> wrote in message
news:%23jORFRfaEHA.3804@TK2MSFTNGP10.phx.gbl...
> This should be straightforward, but ...
>
> What is the correct way to pass an array as a function argument in
> VBScript?
>
> For example, I have a call in an ASP:
>
> <!-- #include file = ../../../functions/dbps.inc -->
> Dim strPjCode
> Dim intVal
> Dim arrValue(50)
> intVal = ProjectSort(strPjCode, arrValue())
>
> The custom function is:
>
> Function ProjectSort(strPjS, arrV())
>
> ProjectSort = 0
>
> etc.
>
> The ASP generates the following error:
>
> Microsoft VBScript runtime error '800a0009'
>
> Subscript out of range
>
> If I remove the () after the array in the ASP and Function I get a
> different error:
>
> Microsoft VBScript runtime error '800a01f4'
>
> Variable is undefined: 'ProjectSort'
>
>
> Any suggestions? Thanks.
>
>
>
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!