Detecting which control raised an event 
Author Message
 Detecting which control raised an event

Hi,

I have a large number of text boxes that all share the same lostFocus event
to run the same sub routine. This is working fine....but how do I get the
name of the control that raised then event?

Thnx,

Stu



Sun, 07 Aug 2005 22:26:22 GMT  
 Detecting which control raised an event

Quote:
> Hi,

> I have a large number of text boxes that all share the same lostFocus
> event to run the same sub routine. This is working fine....but how do
> I get the name of the control that raised then event?

> Thnx,

> Stu

In the event handler, you have the sender object.  It has to be cast to a
TextBox:

        MsgBox("Name of form is: " & CType(sender,TextBox).Name)

Alternately, you can use the Tag property and use the same cast to get the
tag.  

Chris

--
If you don't like lunchmeat, please remove it from my e-mail address to
send me an e-mail



Sun, 07 Aug 2005 22:35:11 GMT  
 Detecting which control raised an event
Stu,

Chris is correct.  I use that tag method because
it is faster than text matching.

Pat

Quote:
>-----Original Message-----



Quote:

>> Hi,

>> I have a large number of text boxes that all share the
same lostFocus
>> event to run the same sub routine. This is working
fine....but how do
>> I get the name of the control that raised then event?

>> Thnx,

>> Stu

>In the event handler, you have the sender object.  It has
to be cast to a
>TextBox:

>            MsgBox("Name of form is: " & CType

(sender,TextBox).Name)
Quote:

>Alternately, you can use the Tag property and use the

same cast to get the

- Show quoted text -

Quote:
>tag.  

>Chris

>--
>If you don't like lunchmeat, please remove it from my e-
mail address to
>send me an e-mail
>.



Mon, 08 Aug 2005 00:18:02 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. raising an event from an activeX control on a htm page in a webbrower control

2. Raising Custom Active X Controls Events when using Data Repeater Control

3. raising an event from an activeX control on a htm page in a webbrower control

4. HELP!!! raising events from a custom control

5. How to Raise/Simluate an Event via Code for a existing Control

6. Help Raising Events in User Controls

7. Q: Raising events in webbrowser control

8. Raising Custom Events in an OCX Control

9. Event from dynamically created control doesn't raise

10. raise event without timer control

11. raise click event on a tabstrip control

12. Raising an event in an Active X control (winsock)

 

 
Powered by phpBB® Forum Software