array subscript out of range 
Author Message
 array subscript out of range

Can anybody explain or provide a good solution to the following problem?

In file1.asp:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim arrMarket
ReDim arrMarket(10)

intArrMarketCount = function_nm(arrMarket)

'arrMarket may or may not contain data after calling function_nm
If  intArrMarketCount = 0 Then
   arrMarket(0)=""
 End If

Function function_nm(arrData )
     Dim i

     i = 0
     Do While Not ...
        i = i + 1
        ...next...
     Loop

     function_nm = i
End Function

In file2.asp:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
<%=arrMarket(0)%>

The problem is:
If arrMarket is null after calling function_nm, I get this error:

Microsoft VBScript runtime error '800a0009'
Subscript out of range

I think I've given a default value to arrMarket(0) in file1.asp, so what
could be the problem, and what's the best solution? Thanks.



Wed, 15 May 2002 03:00:00 GMT  
 array subscript out of range

Michelle,

Quote:
> Subscript out of range

the value of i in funtion_nm is not in the range of LBound to UBound( array )
(probably higher)

Quote:
>      Do While Not ...

What do you control the loop with?

--
Nic Roche
Net Extra
www.extra.net.au
=================================================
imagex - Web Imaging - activex thin client
Button Creator, Thumbnail Creator, Imaging Lite, ImageMap Creator,
MouseOver Creator, SlideShow Creator.
Properties, Methods, Events, Software Developers Kit
=================================================

Quote:

> Can anybody explain or provide a good solution to the following problem?

> In file1.asp:
> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> Dim arrMarket
> ReDim arrMarket(10)

> intArrMarketCount = function_nm(arrMarket)

> 'arrMarket may or may not contain data after calling function_nm
> If  intArrMarketCount = 0 Then
>    arrMarket(0)=""
>  End If

> Function function_nm(arrData )
>      Dim i

>      i = 0
>      Do While Not ...
>         i = i + 1
>         ...next...
>      Loop

>      function_nm = i
> End Function

> In file2.asp:
> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> <%=arrMarket(0)%>

> The problem is:
> If arrMarket is null after calling function_nm, I get this error:

> Microsoft VBScript runtime error '800a0009'
> Subscript out of range

> I think I've given a default value to arrMarket(0) in file1.asp, so what
> could be the problem, and what's the best solution? Thanks.



Sat, 18 May 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Passing Arrays to Functions - Subscript Out of Range Problem

2. HELP! Subscript Out Of Range error referencing array

3. Array Subscript out of range:

4. Defining an array and getting Subscript Out of Range Error

5. subscript out of range? (floating array problem)

6. Arrays Problem SUBSCRIPT OUT OF RANGE

7. Subscript out of range Error when using Arrays

8. "subscript out of range" - Excel

9. Subscript Out Of Range Error

10. subscript out of range

11. Subscript out of range error

12. Subscript Out Of Range

 

 
Powered by phpBB® Forum Software