In VB6 I need to know how to call a button click event on anther form. The another form part is easy but how to pass the click event the proper method to “click” the right button on the toolbar is the real issue.
Here is the vent on the main form – i need to call the click event case “Copyfrom”.
MainForm
Public Sub tbrMain_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Index
Case ToolBarItem.tbPrint
'(some code)
Case ToolBarItem.tbSave
'(some code)
Case ToolBarItem.tbCopyFrom
'(some code)
Case ToolBarItem.tbNEW
'(etc)
I tried
Mainform.tbrMain_ButtonClick()
and even tried passing the index number and key – no dice.
The event handler is expecting to receive a reference to an actual toolbar button, so you have to pass the toolbar button itself, not it’s
CaptionorKey, e.g.:Or, using the
Callstatement:If you set the
Keyproperties on your toolbar buttons, you can use theKeyproperty of the desired button in place of the (1):