Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

single new event handler to handle all commandbutton clicks

Status
Not open for further replies.

fishysheep

Programmer
Oct 13, 2001
54
GB
please to help with this - thank you.

want to write my own event handler (only one) for ALL command buttons on my form.

in gen decs I have written

private sub myclick() handles vb.commandbutton.click

but it gives back error.

many thanks for all the help
 
If you make all your command buttons into an array

then your events will look like this which is for all of the command buttons in the array - which will be a single event for all the buttons

Code:
Private Sub cmdButton_Click(Index As Integer)
[COLOR=green]'Your Code Here[/color]
End Sub


%, 2004
 
Are you using VB5/6 or VB.NET? The <handles> construct only works in .NET

If you're using .NET then try forum796

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
thank you both so very much.

I would not like to use control array as I have already experience of this and know how to make it work. I would like to move up to method I describe above. I am using vb6, not .NET

Just to make more clear. What I want to achieve is to write a single event handler that is to be used in place of the default one that is part of control.

 
Look into subclassing the form. I've never done exactly what you want, but you should be able to handle a click on any, or some, of the buttons (or any other controls) on the form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top