From: Alain Dekker on
I'd like to set a flag called "bEditing" (Dim as Boolean) whenever the user
has entered (called the Enter event) on any of the edit boxes on my form.
Similarly I'd like to set "bEditing" to False when the Leave event is called
on any edit box.

Currently I'm having to set a separate sub-routine for each event for each
edit box. Is there a way to pool them? You could do with Visual C++ 6.0 by
manually editing the message map, and most other languages so I expect
there's away to do it in VB!

Using VB 2003.NET

Thanks!
Alain


From: Rich P on
Try this:

Imports System
Imports ...
...

Dim arrTxt() As TextBox, bEditing As Boolean

Private Sub Form1_Load(...) Handles MyBase.Load
...
arrTxt = New TextBox(){txt1, txt2, txt3, ...}
For Each txt As TextBox in arrTxt
AddHandler txt.Enter, AddressOf txt_Enter
AddHandler txt.Leave, AddressOf txt_Leave
Next
...
End Sub

Private Sub txt_Enter()
bEditing = True
End Sub

Private Sub txt_Leave()
bEditing = False
End Sub


Rich

*** Sent via Developersdex http://www.developersdex.com ***
From: Armin Zingler on
Alain Dekker schrieb:
> I'd like to set a flag called "bEditing" (Dim as Boolean) whenever the user
> has entered (called the Enter event) on any of the edit boxes on my form.
> Similarly I'd like to set "bEditing" to False when the Leave event is called
> on any edit box.
>
> Currently I'm having to set a separate sub-routine for each event for each
> edit box. Is there a way to pool them? You could do with Visual C++ 6.0 by
> manually editing the message map, and most other languages so I expect
> there's away to do it in VB!
>
> Using VB 2003.NET

You can have the same procedure handle the event of all boxes, either by
executing Addhandler for every box, or by naming them all with the Handles
clause:

sub bla(...) handles edit1.leave, edit2.leave, edit3.leave
end sub

--
Armin
From: Alain Dekker on
Thanks very much to you both! That was very helpful and worked exactly as
you said...

Alain


"Rich P" <rpng123(a)aol.com> wrote in message
news:%23GGjNFLtKHA.1440(a)TK2MSFTNGP06.phx.gbl...
> Try this:
>
> Imports System
> Imports ...
> ..
>
> Dim arrTxt() As TextBox, bEditing As Boolean
>
> Private Sub Form1_Load(...) Handles MyBase.Load
> ..
> arrTxt = New TextBox(){txt1, txt2, txt3, ...}
> For Each txt As TextBox in arrTxt
> AddHandler txt.Enter, AddressOf txt_Enter
> AddHandler txt.Leave, AddressOf txt_Leave
> Next
> ..
> End Sub
>
> Private Sub txt_Enter()
> bEditing = True
> End Sub
>
> Private Sub txt_Leave()
> bEditing = False
> End Sub
>
>
> Rich
>
> *** Sent via Developersdex http://www.developersdex.com ***