AddHandler Problem

Enigma151

Newcomer
Joined
Jul 9, 2003
Messages
12
When I try to add the following line, I get an error saying Ctrls_TextChanged is undefined. Any ideas?

AddHandler MyCombo.TextChanged, AddressOf Ctrls_TextChanged

What is the exact address of this procedure/constant? Like system.windows.forms.datagrid.ctrls_textchanged or is there one? My VB likes to be specific :-/
 
Enigma151,

If you right click in the middle of "Ctrls_TextChanged" text in your piece of code that says:

Visual Basic:
AddHandler MyCombo.TextChanged, AddressOf Ctrls_TextChanged

Then you should get a context menu.
On that context menu select "Go To Definition" (should be the 3rd one up from the bottom of the menu).

You will then be taken to the location of the Event Handler (if it exists at all).

georg
 
Erm... there is no "Procedure Constant" -- you need to create it yourself. Somewhere in the form, create this procedure:
Visual Basic:
Private Sub ComboTextChanged(ByVal sender As Object, ByVal e As EventArgs)
  'this code will fire whenever the text of the combo changes
End Sub
 
If you click in the function/sub so the cursor is in the text, you can press [SHIFT]+[F2]. Either the Goto Definition or Shift/F2 will take you to the sub/function.

The Sub Ctrls_TextChanged needs to be created by you. The TextChanged event takes the parameters (ByVal sender As Object, ByVal e As System.EventArgs). So, create your sub as follows:


Private Sub Ctrls_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
' Your code here
End Sub
 
Enigma151,

As VolteFace indicated, I got it (cough) wrong when I told you to use "Go To Definition" to find the Procedure.

You won't be able to "go to the definition" and find the Procedure, because, as your error message and VolteFace so succinctly explained, it does not exist and you need to create it.

georg
 
Back
Top