Solved

Manging array of controls

Posted on 2007-11-29
10
183 Views
Last Modified: 2010-04-30
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
0
Comment
Question by:aft
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 20372382
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
 

Author Comment

by:aft
ID: 20372409
no this is not what i want
i have an array of buttons in my case
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 20372424
Perhaps you should recreate your array of buttons and leave that button out of the array
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:aft
ID: 20372465
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 20373073
Perhaps you could just hide the control and not delete it.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 20374637
"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
 

Author Comment

by:aft
ID: 20387241
no the problem is more complicated than that
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 125 total points
ID: 20387265
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
 

Author Comment

by:aft
ID: 20387289
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
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 20387294
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

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question