RaiseEvent with Ternary Operator

I expected the following to work:

RaiseEvent If(condition, event, event)

But the compiler complains about it:

Error BC30676: "If" is not an event of ...

How to realize a Ternary Operator Statement with RaiseEvents?

Jon Skeet
people
quotationmark

Look at the syntax for RaiseEvent:

RaiseEvent eventname[( argumentlist )]  

It's not that RaiseEvent just accepts any arbitrary expression - you have to specify the name of an event. You'll just need to use a regular If statement:

If condition Then
    RaiseEvent event1
Else
    RaiseEvent event2
End If

people

See more on this question at Stackoverflow