Solved

Manging array of controls

Posted on 2007-11-29
10
161 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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now