Returning an Array from a vbscript function

920 views
Skip to first unread message

Russ

unread,
Nov 28, 2005, 7:16:14 PM11/28/05
to VBScript
I am trying to return an array from a function but I am having
problems. Can someone please help?

With the following code ...

************
Dim ValueArray
ValueArray = MyFunctionToGenerateArray ()
for i = 0 to Ubound(ValueArray) <-------- error pointing here.
Response.Write(ValueArray(i) + "<br/>")
next

...

function MyFunctionToGenerateArray ()
MyFunctionToGenerateArray = Array(1,2,3,4,5,6,7,8,9)
end function
************

I get the following error ...

Microsoft VBScript runtime error '800a000d'
Type mismatch: 'Ubound'
/SAW/PostListener.asp, line 88

********************************************************************
If I change the code to this ...


************
Dim ValueArray()
Redim ValueArray(10)
ValueArray = MyFunctionToGenerateArray () <-------- error pointing
here.

for i = 0 to Ubound(ValueArray)
Response.Write(ValueArray(i) + "<br/>")
next
************

I get the following ...

Microsoft VBScript runtime error '800a000d'
Type mismatch


I know this should be simple, but I just cant figure it out.

Ro...@admissionpros.com

unread,
Nov 29, 2005, 9:00:00 AM11/29/05
to VBScript
Try This...

Dim ValueArray
Dim i

ValueArray = MyFunctionToGenerateArray ()

for i = 0 to Ubound(ValueArray)

Response.Write(ValueArray(i) & "<br/>")
next

Reply all
Reply to author
Forward
0 new messages