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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a click event from another form (VB6) 1

Status
Not open for further replies.

Sashanan

Programmer
Jan 19, 2001
235
NL
Maybe I'm missing something obvious here, but how do I call a click event (on a command button or a menu item) from another form?

When I'm on the form myself, using the line

cmdMyButton_click

works just fine, but when I try

MyForm.cmdMyButton_click

from another form, I get a "Method or data member not found". Any insights?


"Much that I bound, I could not free. Much that I freed returned to me."
(Lee Wilson Dodd)
 
you won't be able to because the cmdMyButton_Click is a private sub to that form only.
It is bad coding to pass that sub to other forms.
You could set up a class that does the commands in the click event so that you can call it at any time.

To go where no programmer has gone before.
 
Ack of course, it *is* private...so I could set it public, which is unelegant but functional? I'll go with that first but also look into the class possibility.

Thanks!


"Much that I bound, I could not free. Much that I freed returned to me."
(Lee Wilson Dodd)
 
cclint is right. I've done exactly that myself.

--Bill
One may not reach the dawn save by the path of the night
--Kahlil Gibran
 
That was a new one to me, and it indeed worked. I've gone with the original suggestion though and moved the code to module level, where both forms access it without the fuss of one form calling a button click event of the other.


"Much that I bound, I could not free. Much that I freed returned to me."
(Lee Wilson Dodd)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top