Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Controls array ref
Message
 
To
All
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Title:
Controls array ref
Miscellaneous
Thread ID:
00904086
Message ID:
00904086
Views:
66
Hi All:
I need serious help on how to remove the controls array object from memory. I want to be able to reload my control array with different objects everytime the user click on a command button. My code works fine the first time, however it errors out the second time when I click on the command button. The error I get is "The key is already associated with an element of this collection."

Thus,how can I remove a reference to the controls array and the object I added to that control from memory?

Here is my code:

Dim colScroll As New Collection

If sFrame = "Frame" & CStr(1) Then
****Executed the second time user clicks on the button
***these are the items I want to remove
colScroll.Remove sFrame
Controls.Container.Remove "Combo" & CStr(0) ****Problem is happening here*
Controls.Container.Remove "Text" & CStr(0) **** *
Else
****First time, works fine
sFrame = "Frame" & CStr(1)
Controls.Add "VB.Frame", sFrame, Me
End If


'Position the frame and set its properties.
With Controls(sFrame)
.Top = 3960
.Left = 240
.Height = 1815
.Width = 5200
.BorderStyle = 0
.Visible = True
.ZOrder (0)
End With
' Maintain a collection of scrollbar values
colScroll.Add 0, sFrame
' Add 3 new controls to the frame.

I am sort of lost at this time and any idea or point me to the right direction would be greatly appricated.

Thanks
MA
Reply
Map
View

Click here to load this message in the networking platform