Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Manging array of controls

Posted on 2007-11-29
10
Medium Priority
?
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 86

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 86

Accepted Solution

by:
Mike Tomlinson earned 500 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 86

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

721 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