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

Need help deleting collections efficiently

Status
Not open for further replies.

Karl Blessing

Programmer
Feb 25, 2000
2,936
US
I have a collection, with many more collections under it, after getting a few out of memory error, I come to realize that just deleting the top collection doesnt automatically clean out the collections below it, anyone have an idea on how to make it so that I free every collection item, of the main, and all the collections below it? <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
'Original SubRoutine<br>'Public Sub ShapeClear()<br>'Dim Num As Integer<br>'For Num = 1 To Shapes.Count<br>'&nbsp;&nbsp;&nbsp;Shapes.Remove 1<br>'Next Num<br>'End Sub<br>'Below is new one I *think* would work<br>Public Sub ShapeClear()<br>Dim Num As Integer<br><br>For Each ShapeL In Shapes<br>&nbsp;&nbsp;&nbsp;&nbsp;For Each Sic2L In ShapeL.Sic2<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;For Each Sic4L In Sic2L.Sic4<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sic2L.Remove Sic4L<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Next<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ShapeL.Remove Sic2L<br>&nbsp;&nbsp;&nbsp;&nbsp;Next<br>&nbsp;&nbsp;&nbsp;&nbsp;Shapes.Remove ShapeL<br>Next<br>End Sub<br> <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
Public Sub ShapeClear()<br>Dim Num As Integer<br>Dim TmpShap As Shapes, TmpSic2 As Sic2, TmpSic4 As Sic4<br><br>For Each TmpShap In Shapes<br>&nbsp;&nbsp;&nbsp;&nbsp;For Each TmpSic2 In TmpShap.Sic2<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;For Each TmpSic4 In TmpSic2.Sic4<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TmpSic2.Sic4.Remove TmpSic4.Siccode<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Next<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TmpShap.Sic2.Remove TmpSic2.Siccode<br>&nbsp;&nbsp;&nbsp;&nbsp;Next<br>&nbsp;&nbsp;&nbsp;&nbsp;For Each TmpSic4 In TmpShap.Sic4<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TmpShap.Sic4.Remove TmpSic4.Siccode<br>&nbsp;&nbsp;&nbsp;&nbsp;Next<br>&nbsp;&nbsp;&nbsp;&nbsp;Shapes.Remove TmpShap.Name<br>Next<br>End Sub<br><br>think that works, but have no idea how to test it for memory leaks <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top