problem with delegates

  • Thread starter Thread starter Boni
  • Start date Start date
B

Boni

Dear All,
I would like to pass delegate (i.e function pointer ) into class
--------------------------
delegat TAAADelegate()
class A
dim myhandler as TAAADelegate
sub initialize ( handler_ as TAAADelegate)
myhandler=handler_
end sub

public shared sub Handler1()
end sub

end class
 
Boni said:
Dear All,
I would like to pass delegate (i.e function pointer ) into class
--------------------------
delegat TAAADelegate()
class A
dim myhandler as TAAADelegate
sub initialize ( handler_ as TAAADelegate)
myhandler=handler_
end sub

public shared sub Handler1()
end sub

end class

It helps if you actually copy and paste directly from the editor :)
delegat TAAADelegate()

Guessing this is meant to be

Delegate Sub TAAADelegate()
dim oA as new A
A.initializelize(A.Handler1) 'Compiler complains
A.initializelize(addressof A.Handler1) 'Compiler complains

- The sub is called 'initialize' not 'initializelize'
- 'initialize' is an instance method not a shared method, so should be
invoked on oA not A

Once those changes are made, this compiles:

Dim oA As New A
oA.initialize(AddressOf A.Handler1)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top