Passing an address as an argument

  • Thread starter Thread starter Just Me
  • Start date Start date
J

Just Me

I have these three statements:

gFormCheckForCancel = New FormCheckForCancel

AddHandler gFormCheckForCancel.Cancelled, AddressOf UserCancelled

gFormCheckForCancel.ShowForm()



I'd like to move

AddHandler gFormCheckForCancel.Cancelled, AddressOf UserCancelled

to ShowForm()

and pass

AddressOf UserCancelled

as an argument of ShowForm()



But I don't know how.

Can someone tell me?
 
Hi,

Take a look at delegates

http://msdn.microsoft.com/library/d.../cpref/html/frlrfsystemdelegateclasstopic.asp

Ken
-------------------------
I have these three statements:

gFormCheckForCancel = New FormCheckForCancel

AddHandler gFormCheckForCancel.Cancelled, AddressOf UserCancelled

gFormCheckForCancel.ShowForm()



I'd like to move

AddHandler gFormCheckForCancel.Cancelled, AddressOf UserCancelled

to ShowForm()

and pass

AddressOf UserCancelled

as an argument of ShowForm()



But I don't know how.

Can someone tell me?
 
I know a little about them. I've even used MouseEventHandler in a similar
situation.
But do not know what to use here.


Thanks
 
I think I found how to do it. Seems
Public Event Cancelled(ByVal sender As Object, ByVal e As EventArgs)

creates a type CancelledEventHandler.



I still do not understand some things.

I believe Cancelled, as defined above, is a delegate, but

is it a class or a type.



Help sometimes seems to use delegate as a class and sometimes as a type.

I don't understand when a delegate is a class and when it is a type.



Thanks
 
Hi,

Declare a delegate sub and pass a variable of the delegate sub name.


public delegate sub MySub(byval Arg1 as integer)

dim MyAddressOf as new mysub(addressof theSub)

Ken
 
thanks

Ken Tucker said:
Hi,

Declare a delegate sub and pass a variable of the delegate sub
name.


public delegate sub MySub(byval Arg1 as integer)

dim MyAddressOf as new mysub(addressof theSub)

Ken
 

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