• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 168
  • Last Modified:

Delete a button or label


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)


2 Solutions
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 :)
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.
TungVanAuthor Commented:


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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Bob LambersonSoftware 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.

Try this

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.
Can I ask why this only rated a B?

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now