Missing Handles

jswota

Well-known member
Joined
Feb 23, 2009
Messages
49
Programming Experience
Beginner
Hi,

Sometimes i cut and paste form objects forgetting that as soon as i do all of the deleted objects Event Handles are removed from the code. It's usually me monkeying around and forgetting that this happens.

My question is how can i find all procedures that do not have a defined event handler?

I.e.

VB.NET:
Private Sub MySub()
  'Some Code
End Sub

Is there some way to do this in visual studio?

Thanks,
Joel
 
Sometimes i cut and paste form objects forgetting that as soon as i do all of the deleted objects Event Handles are removed from the code. It's usually me monkeying around and forgetting that this happens.
Drag-drop instead, or if moving to other forms for example first move code then controls.
My question is how can i find all procedures that do not have a defined event handler?
Since these are regular methods you have to rely on the common event pattern, and can therefore do pattern matching (regex) using the Find dialog (tick option 'Use Regular Expressions' of course). For example:
VB.NET:
Private Sub .+\(.+EventArgs\)$
This matches Private Subs named anything, that has a parameter list that ends with 'EventArgs', and nothing following (ie no Handles clause). Standard events always has a 'sender As Object, e As anyEventArgs' parameter list.
 
Hi John,

Thanks for the reply. Perfect answer! Good tip about drag/drop and moving code first.

Thanks again,
Joel
 
Back
Top