Manging array of controls

Hello

i have a problem as follow:
i created an array of command buttons. their index are from 0 to 4. i remove one of them with index 3 using code (unload buttons(3)). i want to make the index of button(4) =3 and index of Button(5)=4. how can i do that. i want that because in every for loop this make a problem to me with the missing item.

regards
aftAsked:
Who is Participating?
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
The Index() property of a standard control array is read-only...so the only way to do this is to physically cycle thru the controls and copy all of the properties to the new position...and then unloading the last item in the array.

Other than that suggestion, we would need to no want you are ACTUALLY doing....please explain what "complicated" means.
0
 
DhaestCommented:
i think you need to resize the array

ReDim Preserve avRemoveFrom(lLBound To lUbound - 1)

Take a look at http://www.visualbasic.happycodings.com/API_and_Miscellaneous/code37.html
0
 
aftAuthor Commented:
no this is not what i want
i have an array of buttons in my case
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
DhaestCommented:
Perhaps you should recreate your array of buttons and leave that button out of the array
0
 
aftAuthor Commented:
i want more easy solution
because it is too hard too do that in my application. i hide many details about my application here for simplicity
0
 
GrahamSkanRetiredCommented:
Perhaps you could just hide the control and not delete it.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
"i want that because in every for loop this make a problem to me with the missing item."

Use Error Handling (On Error Goto xxx/Resume yyy) to trap the error generated by the "hole" in your control array.  This will allow you to skip over the indexes that have had the control unloaded...


0
 
aftAuthor Commented:
no the problem is more complicated than that
0
 
aftAuthor Commented:
ok

i have a video transmission program that work as follows:
1. each user has a server program that read the video frames from the camera it is connected to his local computer.
2. i have the client program on my computer that has a list control containing all the users. when i click each user, the program create a window that render the video from the clicked server. when i uncheck the user, its window removed and the windows after it shifts one step up
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
So is it a matter of correctly correlating the ListBox entry with the correct connection (Winsock control array?) after an entry has been removed from the middle of the "user list"?

Are we dealing with Winsock control arrays?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.