How to do a delegate

I need to call a function in a class which can be defined anywhere in the app.
I think delegate is the right choice to do it, how can I do it ?

in a class a1 I defined a delegate by adding it from the insert delegate command,
in a window w1 where I use class a1 I have a function which I would like to call in class a1.
also in window w1 I tried to load the delegate of class a1 with AddressOf window.function but get a compile error.

How can I solve my problem?

Make sure you refer to the instances, not the class names. We’d need more information in order to be more specific. Something like

PropertyOfTypeA1.TheDelegateProperty = AddressOf w1.FunctionName

it’s working now, I missed the property which I had to declare

thanks Tim

Great to read you could be helped, Johann! May I encourage you to click the “this has answered my question” button on Tim’s post? This makes it easier for others with the same question to see they will find the answer in your thread.

Thank you!

Here, by example what Tim said: