is this a bug? raiseevent problem

1,create class Class1,add event , and a method Hello adds to “methods”. which is nothing different from a normal method.
and create a nother method “Fireit”

sub fireit
raiseevent Hello
end

I use Class1 to window1 as proterty “testingObj”

when call testingObj.fireit

hints “Hello” not found in the project.

You have to define the event “Hello”, not add it as a method.

dear kem yes I define a event,but the IDE auto change it to “methods”,not know why

Just to be clear, you are choosing “Event Definition” from the Insert menu?

right click the “Class1”,
choose “add to Class1”,
and in the submenu, choose “Event” or Choose “Method” all will insert to “methods”

I think you’re missing it. Not “Event”, “Event Definition”.

ok, my doubt is why “event” change to “methods”

and I try “event definetion”,

but can’t figure out a way to relize the event.

what I declare is:

class1 HelloEvent (no params no returns)

Window1 Hello (no params no returns)
in window1.open

someobj=new Class1
Addhandler someobj.HelloEvent addressof Hello

and Run it error .

It’s hard to tell exactly what you’re doing. But in general, you add an event definition to a class. The class can call/raise the event, but it cannot implement the event. A subclass of the class can implement the event and add code to it, but it cannot call the event unless you add an additional event definition to the subclass. If so, then calling/raising the event will call the code in a subclass of the subclass, but not in the subclass itself.

In your example, the method Hello would have a single parameter of type Class1. AddHandler implicitly adds an extra parameter to the beginning of the parameter list which is a reference to the object whose event you are handling. (also, you seem to be missing the comma between someobj.HelloEvent and AddressOf.)

For example,

dim mytimer as timer = new timer
AddHandler mytimer.Action, addressof myTimerAction
Sub myTimerAction(t as timer)
    // action code here
End Sub

When myTimerAction is triggered, it’s parameter “t” will be a reference to the timer object “mytimer”.

that’s ok .thanks