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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arrays and grid

Status
Not open for further replies.

AFK1

IS-IT--Management
Aug 26, 2005
38
US
When I loop through my array in same application 2nd time, then it boms and gives error Subscript out of range (Error 9).
I loop through array when someone clicks the grid. First time , grid click works fine. then when I click on a Button to get someother info and then click on grid again it boms.
Can someone help please..
 


Could you show some code example, we would have a better ideal of your problem.(ie. not resetting you loop counter)
 


i=0

vBookmark = (CInt(grd.selBookmarks(iRow)))
sItemID=vBookMark
'check if I have rows in my Grid array
If mlarrayMaxRows<> 0 Then
'Loop through rows
Do While i <= mlarrayMaxRows
'check if my second array value is same as grid array.
If Array(ITEM, i) = sItemID
---something here
If Not Array(QTY, i) Then
txtQty.Text = Array(QTY, i)
Else
txtQty.Text = ""
End If
cbo.Text = Array(LINE, i) + Space(5) + Array(ITEM, i)
Endif
i =i +1
Loop

So first click works. But when I click on something else, another button, and then click on grid again, I will get that error. Also in My save I call this subrooutine, and it boms too. My guess is the grid may looses focus. But how can i do that as in Save, no one has to click on grid, i just want to capture the bookmark of the row.

 
Looks like this thread again... thread222-1171566
Sorry AFK1 if I sort of started asking question in the thread. But hopefully now you can try the for next approach using LBound and UBound and stop getting the pesky subscript out of range error. :)
 
No...Actually I though its not the array but may be its my grid.thats why i started new thread.

But just now I find out that during my call to thebutton, i was erasing my array.

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top