Skip to Content
Aug 25, 2016 at 01:47 PM

What are the different methods of Handling Events?


Hi, everybody

I am a bit confused about how to handle events.

I am not a professional programmer, and very often, I copy codes from the SDK forum and adapt them to my requirements.

My add-ons finally work, but I don't always understand the basic principles behind.🤪

If I had to master all programming concepts before starting to develop add-ons, I would still be learning...😉

Without realizing it, while copying codes from the forum, it seems to me that I have been using 2 different methods of handling events, and have obtained satisfactory results from both methods.

I don't know the names of the 2 methods, but here are some codes to help you recognize them.

Method 1

Let's call it: Event Type method

If FormUID = "abcde" And pVal.ItemUID = "Btn1" And pVal.InnerEvent = False And pVal.BeforeAction = False And pVal.EventType = SAPbouiCOM.BoEventTypes.et_CLICK Then

. . .

. . .

End If

Method 2

Let's call it: Handler Method

RemoveHandler B_OK.PressedBefore, AddressOf OnBeforeB_OKPressed

AddHandler B_OK.PressedBefore, AddressOf OnBeforeB_OKPressed

- - - - - -

Private Sub OnBeforeB_OKPressed(ByVal Source As Object, ByVal pVal As SAPbouiCOM.SBOItemEventArg, ByRef Bubble As Boolean)

. . .

. . .

End Sub


How many different methods of handling events are there?

Do they have names?

What are the differences between these methods?

Which method is better?

Which method is more likely to be still supported by SAP in say 10 years?


Leon Lai