tags:

views:

34

answers:

1

I want to add an event in my VB.NET code. I have done VB.net programming but not well experienced in event handling.

I have declared like this

public WithEvents FormEventCapture As vFormAgent.__vFormAgentLib_Event 

Then i put the following code in form load event

FormEventCapture = new vFormAgent.__vFormAgentLib_FormEventEventHandler()

AddHandler FormEventCapture.FormEvent, AddressOf Me.FormEventCapture_FormEvent

Is it correct?

When i compile i get the following error

Delegate 'vFormAgent.__vFormAgentLib_FormEventEventHandler' requires an 'AddressOf' expression or lambda expression as the only argument to its constructor. (BC32008) 

So i need to pass an argument to this constructor then i changed as follows

FormEventCapture = new vFormAgent.__vFormAgentLib_FormEventEventHandler(AddressOf Me.FormEventCapture_FormEvent)

Then i get the following error

Lambda expression cannot be converted to 'vFormAgent.__vFormAgentLib_Event' because 'vFormAgent.__vFormAgentLib_Event' is not a delegate type. (BC36625) 

I am not able to figure out what is the problem.

Can any one tell me what is the problem?

A: 

Hello Everyone

I could figure out what is the problem.

FormEventCapture_FormEvent should have same signature as delegate function i.e. __vFormAgentLib_FormEventEventHandler.

When i changed the signature of the FormEventCapture_FormEvent , it did not give the error.

But i am getting some run time error, If i do not succeed in figuring out i have ask you all for help.

Thanks.