Protected Overridable Sub Whatever()
...
End Sub
Can anyone tell me what exactely the "Overridable" keyword is used for? What does it do and why would someone use it?
Printable View
Protected Overridable Sub Whatever()
...
End Sub
Can anyone tell me what exactely the "Overridable" keyword is used for? What does it do and why would someone use it?
a good example of how an override sub works is this... looking at the form's KeyPreview and catching the keyboard buttons that you cant see getting pressed on keydown ( left , right , up , down ), override gives you more control over whats happening and allows you to prevent things happening ( True / False )
VB Code:
[color=blue]Protected[/color] [color=blue]Overrides Function[/color] ProcessKeyPreview([color=blue]ByRef[/color] m [color=blue]As[/color] System.Windows.Forms.Message) [color=blue]As Boolean[/color] [color=blue]Select Case[/color] m.WParam.ToInt32 [color=blue]Case[/color] 37 '/// left arrow '// do stuff [color=blue]Case[/color] 38 '/// up arrow '// do stuff [color=blue]Case[/color] 39 '/// right arrow '/// do stuff [color=blue]Case[/color] 40 '/// down arrow '/// do stuff [color=blue]End Select[/color] [color=blue]Return True[/color] [color=blue]End Function[/color]
When you create a class which inherits from the class with the overridable method/function, you can override this method/function using 'overrides', the inherited class can have its own implementation of that method/function.