Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script out of range error

Status
Not open for further replies.

Scouseman

Technical User
Mar 25, 2003
22
US
Hi

I wonder if someone can help me I have coded a module and cannot work out why I am getting a out of range error can anyone help, here i my code:

************************module*********************
Option Explicit

Private m_arrOrders() As Variant
Private m_myID As Long
Private m_theirID As Long
Private m_nextID
Private m_incrament As Integer

Function Get_Set_NewOrderID(ByVal Mirror As Variant) As Long

Dim iTemp As Integer

If m_theirID < m_myID Then
m_nextID = m_myID
m_myID = m_myID + m_incrament
Else
m_myID = m_theirID - 1 + m_incrament
m_nextID = m_myID
m_myID = m_myID + m_incrament
End If

m_arrOrders(0, UBound(m_arrOrders, 2)) = m_nextID

For iTemp = 1 To UBound(m_arrOrders)
m_arrOrders(iTemp, UBound(m_arrOrders, 2)) = Mirror(iTemp)
Next iTemp

ReDim Preserve m_arrOrders(12, UBound(m_arrOrders, 2) +1)


Call DisplayArray

Get_Set_NewOrderID = m_nextID


End Function

The error is on this line:

m_arrOrders(0, UBound(m_arrOrders, 2)) = m_nextID

Thanks for any help

Scouseman
 
Move your re-dim statement.

For iTemp = 1 To UBound(m_arrOrders)
ReDim Preserve m_arrOrders(12, UBound(m_arrOrders, 2) +1)
m_arrOrders(iTemp, UBound(m_arrOrders, 2)) = Mirror(iTemp)
Next iTemp



Experience is something you don't get until just after you need it.
 
MSDN:
=======
You can also use the Dim statement with empty parentheses to declare a dynamic array. After declaring a dynamic array, use the ReDim statement within a procedure to define the number of dimensions and elements in the array.


Redim m_arrOrders (1,1)



I was standing in the park, wondering why frisbees got bigger as they came closer... then it hit me!
 
Hi bigalbigal

I tried your suggestion but I am still getting an out of range error.

Scouseman
 
Scouseman,

How many dimensions is m_arrOrders (1 or 2)?

(I'm a Wigan man myself)


Experience is something you don't get until just after you need it.
 
Hi bigalbigal

m_arrorders is a 1 dimensional array

It just shows you what a small world it is!! (Can I mention football)

Thanks for your help

Scouseman
 
I can only suggest you try adding another redim above the line m_arrOrders(0, UBound(m_arrOrders, 2)) = m_nextID

What's football? [thumbsdown]

Experience is something you don't get until just after you need it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top