rkrishc
asked on
Control array problems
Hi,
I'm using control array to create controls at runtime on a tabstrip. I have a command button on the form with index = 0 and I create more buttons using
iNextBtn = btnClose.Count
Load btnClose(iNextBtn)
With btnClose(iNextBtn)
.caption = "&Close"
.Tag = sNamedCell
Set .Container = Controls(sNamedFrame)
End With
and when the tab has to be closed, I unload the button with
Unload btnClose(iBtnIndex)
However, when I unload the button with index say 1 and then subsequently try to load the button with the same Index, I get a runtime error that the item is already locked. I'd like to know why this happens. I can find a way to work around this, but I'd like to understand why I get the runtime error.
TIA
-RK
I'm using control array to create controls at runtime on a tabstrip. I have a command button on the form with index = 0 and I create more buttons using
iNextBtn = btnClose.Count
Load btnClose(iNextBtn)
With btnClose(iNextBtn)
.caption = "&Close"
.Tag = sNamedCell
Set .Container = Controls(sNamedFrame)
End With
and when the tab has to be closed, I unload the button with
Unload btnClose(iBtnIndex)
However, when I unload the button with index say 1 and then subsequently try to load the button with the same Index, I get a runtime error that the item is already locked. I'd like to know why this happens. I can find a way to work around this, but I'd like to understand why I get the runtime error.
TIA
-RK
Could you please post your code where the error is raised?
You might try this:
Unload btnClose(iBtnIndex)
Set btnClose(iBtnIndex) = Nothing
Unload btnClose(iBtnIndex)
Set btnClose(iBtnIndex) = Nothing
I haven't seen all your code but are you declaring the array as myarray() AS control.
I usually use collections there easy to program and have a much more sophisticated item handling abilities.
I usually use collections there easy to program and have a much more sophisticated item handling abilities.
Check your tabstrip control, maybe it hold btnClose(1)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi rkrishc,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Accept TimCottee's comment(s) as an answer.
rkrishc, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you. DO NOT accept this comment as an answer.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Accept TimCottee's comment(s) as an answer.
rkrishc, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you. DO NOT accept this comment as an answer.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
per recommendation
SpideyMod
Community Support Moderator @Experts Exchange
SpideyMod
Community Support Moderator @Experts Exchange