I am using a collection in order to track controls added
during runtime. How do I delete these controls when I am finished with them?
Printable View
I am using a collection in order to track controls added
during runtime. How do I delete these controls when I am finished with them?
[Edited by kedaman on 10-13-2000 at 04:55 PM]Code:unload coll(Index)
coll.Remove Index
Deleting controls is the same as "deleting" (called closing in programming terminology) an App.
Add the following to a Form with 2 CommandButtons called Command1 and Command2. When you press Command2, it will close (delete) Command1.
Code:Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Const WM_CLOSE = &H10
Private Sub Command2_Click()
SendMessage Command1.hwnd, WM_CLOSE, 0, 0
DestroyWindow Command1.hwnd
End Sub