Delete a button or label



Hi,

I have a map, and on this map, I have multiple buttons and labels. I have Delete option under Edit menu. When i click on delete, this is the skeleton that it gives to me:

Private Sub mnuEditDelete_Click()

End Sub


Since there is no index...how can I know which button or label i delete...
cmdbutton(0), .....cmdbuttton(x)
lblLabel(0),...lblLabel(x)



Thaks

TungVanAsked:
Who is Participating?
 
sk33v3Connect With a Mentor Commented:
Try this
www.grbackup.com/ee/dynamic_controls/Remove_controls.zip

please note the on error resume next. That is placed there because if you remove a control and then try to set a property of that control it will generate an error. Also note that you can not remove the label(0) because that was created at design time. you may only destroy object that you create during runtime.
0
 
gecko_au2003Commented:
When you click on delete on the menu do you want it to delete all buttons and or labels or are you just trying to delete one at a time, If you created the buttons and labels as a control array then you should be able to prompt the user with an input box prompting for which one you want deleting.

Basically make it so that the delete option in the menu is only enabled after they have clicked on one of the controls that are in the control array and then if they click on delete, then make it delete the last item they clicked on within the control array so if you had 10 buttons within a control array and then 10 labels within the control array, if they clicked on button(10) then you could have a public variable that stored the last item they clicked on ie

Public itmStore As Integer

Public Sub cmdButton_Click(Index As Integer)
itmStore = Index
End Sub

Private Sub mnuEditDelete_Click()
Delete cmdButton(itmStore) '< -- I am not sure of what the delete or remove command is but I am sure this will make sense
End Sub

The coding would be something like that but I am not sure of what the delete command would be exactly, but this should give you a good idea of what to do :)
0
 
sk33v3Commented:
If you mean in the VB IDE, in your properties window (I have mine on the right side of the screen) whatever object you have selected will be deleted. if you have multiple items selected then the name will obviously be displayed in the properties window.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
TungVanAuthor Commented:

>sk33v3

I don't refer to VB IDE unfortunately....

0
 
Bob LambersonConnect With a Mentor Software EngineerCommented:
you could do something like change the color of the control to delete in it's click event, and record it's name in a form variable.

then when your user clicks on the menu_delete, that event could hide or delete whatever control in named in the form variable.

Bob
0
 
sk33v3Commented:
Can I ask why this only rated a B?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.