Hello,
I posted on the DotNet reddit with zero feedback. Is it impossible to raise a base class event from a derived (child class that inherits base) class in VB?
This is a trivial request and I am unable to get a subscriber of the event to receive the event.
Many posts online and through MS Docs says to build a base class wrapper that protected sub to call the base class event. This didn't work either. So I tried that.
Consider the following example
(Apologies I'm on mobile - no way to add code tags?
Code Example:
	
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
	
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
	
		
			
		
		
	
				
			I posted on the DotNet reddit with zero feedback. Is it impossible to raise a base class event from a derived (child class that inherits base) class in VB?
This is a trivial request and I am unable to get a subscriber of the event to receive the event.
Many posts online and through MS Docs says to build a base class wrapper that protected sub to call the base class event. This didn't work either. So I tried that.
Consider the following example
(Apologies I'm on mobile - no way to add code tags?
Code Example:
			
				VB.NET:
			
		
		
		    Public Class ParentTest
        Public Event OnEventFire()
      
      
        Protected Sub RaiseParentEvent() 'helper sub? See MS article.
            RaiseEvent OnEventFire()
            Debug.Print("Parent event was raised.")
      
        End Sub
      
  
        Public Class ChildTest
            Inherits ParentTest
            Sub EventWasTriggered()
      
                'call parent helper sub
                RaiseParentEvent()
      
            End Sub
      
        End Class
    End Class
			
				VB.NET:
			
		
		
		    Class MainProgram
        Private WithEvents parent As New ParentTest
      
      
        Sub RunProgram()
      
            Dim child As New ParentTest.ChildTest
      
            'subscribe to the parent event
            AddHandler parent.OnEventFire, AddressOf ReceiveEvent
      
      
            'trigger event...
            child.EventWasTriggered()
      
        End Sub
      
        'trigger
        Private Sub ReceiveEvent() Handles parent.OnEventFire
            MsgBox("FIRE!")  '<---- never fires when RunProgram() is called!
        End Sub
    End Class 
	 
 
		 
 
		 
 
		 
 
		