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

Deleting Control Array Items

Status
Not open for further replies.

Cndn

Programmer
Nov 22, 2001
22
0
0
CA
I've got a little arcade WWII fighter planes game of mine in the works right now. For all the enemy planes, bombing targets, explosions, etc. I'm using shape control arrays and creating new items in the arrays when they are needed in the game. The problem is that I don't know how to delete control array items that are no longer needed, so my game becomes so slow and bogged down that it's impossible to play. So my only options are either to buy the chess playing super computer 'Deep Blue', or find a way to elimanate control array items I no longer require.

P.S. Thanks to Foada for all the helpful posts on my control array questions.
 
Use Unload ControlArrayName(index) but be careful about doing it in any event of the control array. What I do is make the control invisible and when I want a new one I look for an unused one and only create a new one if needed.. Use For/Each instead of an index to avoid a problem.
Dim ctl as whatever
Dim lngNew as Long
Do
For Each ctl in ControlArrayName
if ctl.Visible = true then exit do
Next
lngNew = ControlArrayName.Ubound + 1
Load controlarrayname(lngNew)
Set Ctl = ControlArrayName(lngNew)
Exit Do: Loop
' ctl is the usable control Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top