Function Overriding in Visual Basic .NET

You have function named CalculateSalary() in your base class. But you want to changes the function behavior of your derived class. So what you can do is to override base class function in your derived class

Lets see how we can do this
We have People base class code here and you can see the CalculateSalary() method too. You have to use Overrridable keyword in base class function so that you can override the function or property in derived class

Now you can override the CalculateSalary() method in your derived class called Employee. In the CalculateSalary() method you have to use the keyword Overrides

Now lets create the object in our main module and see the output


You can see that CalculateSalary() of the derived class executes