How to trigger the object's event which pass by reference to a function? 
Author Message
 How to trigger the object's event which pass by reference to a function?

i.e. I pass a button object into a function like this:

Function DoSomething(ByRef btn as Button) As Boolean
    btn_Click    ' I wish to call the btn event onclick
End Function

How? anybody can help?

Thank you very much.



Tue, 08 Feb 2005 10:00:06 GMT  
 How to trigger the object's event which pass by reference to a function?

Quote:
> i.e. I pass a button object into a function like this:

> Function DoSomething(ByRef btn as Button) As Boolean
>     btn_Click    ' I wish to call the btn event onclick
> End Function

I'm afraid that you can't do it that way.

Somebody better than me might be able to tell you how to send a message to
the button. That message of course should be a mouse click. This solution
will require you to get hold of some external (API) functions.

What I would do in straight VB is to put a big switch into the DoSomething
sub. I would then switch on the buttons Name property, and call the
appropriate btn_Click.

Keld Laursen



Tue, 08 Feb 2005 14:25:06 GMT  
 How to trigger the object's event which pass by reference to a function?
I'm not 100% sure that's true.  If the button exists already and the event
handler is already written, you should be able to pass the button to a
procedure just fine.  To call the Click event of a button, just set the
button to True:

Sub MySub(btn As Button)
    btn = True
End Sub

--
Chris Tacke, eMVP
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


Quote:


> > i.e. I pass a button object into a function like this:

> > Function DoSomething(ByRef btn as Button) As Boolean
> >     btn_Click    ' I wish to call the btn event onclick
> > End Function

> I'm afraid that you can't do it that way.

> Somebody better than me might be able to tell you how to send a message to
> the button. That message of course should be a mouse click. This solution
> will require you to get hold of some external (API) functions.

> What I would do in straight VB is to put a big switch into the DoSomething
> sub. I would then switch on the buttons Name property, and call the
> appropriate btn_Click.

> Keld Laursen



Tue, 08 Feb 2005 20:00:21 GMT  
 How to trigger the object's event which pass by reference to a function?


Quote:

> Sub MySub(btn As Button)
>     btn = True
> End Sub

Nice tip. Thanks.

Keld Laursen



Tue, 08 Feb 2005 21:06:12 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to trigger the object's event which pass by reference to a function?

2. Passing an object reference by reference where the object has a default property

3. Problems with callback reference to a COM object - which isn't a source of events

4. COM object events can't pass UDTs?

5. Event not triggering function call in parent

6. Event not triggering function call in parent

7. Triggering Command Button's On_Click Event from Code

8. Using the computer's clock to trigger an event

9. OnAction() event doesn't trigger

10. How do I trigger a Mousemove Event when moving away from an object

11. Drag-drop events don't trigger in listview

12. Missing Viewer's Form_Activate event triggering

 

 
Powered by phpBB® Forum Software