title: Cannot get derived class to perfom function
body: <p>I am working on an assignment where I have to create a base class named Bonus. The class should contain two Public properties: a String property named SalesId and a Double property named Sales. I also have to include a default constructor and a parameterized constructor in the class. Also include a GetBonus method (function) that calculates a salesperson’s bonus using the following formula:
  sales* .05</p>
  
  <p>Then create a derived class named PremiumBonus. The derived class’s GetBonu method should calculate the commission as follows:
  sales * .05 + (sales – 2500) * .01. </p>
  
  <p>Be sure to include a default constructor and a parameterized constructor in the derived class.</p>
  
  <p>This is what I have so far but its only calculating the Bonus not the PremiumBonus when necessary.  </p>
  
  <p>Payroll.vb</p>
  
  <pre><code>Option Explicit On
  Option Strict On
  Option Infer Off
  
  ' base class
  Public Class Bonus
      'declare properties
      Public Property SalesId As String
      Public Property Sales As Double
  
      'default constructor
      Public Sub New()
          _Sales = 0
          _SalesId = String.Empty
      End Sub
  
      'parameterized constructor
      Public Sub New(ByVal strId As String, ByVal dblB As Double)
          _Sales = dblB
          _SalesId = strId
      End Sub
  
      'method to calculate the bonus using formula
      Public Overridable Function GetBonus() As Double
          'returns the sales person's bonus
          Return _Sales * 0.05
      End Function
  End Class
  
  
  ' derived class
  Public Class PremiumBonus
      Inherits Bonus
  
      Public Sub New()
          MyBase.New()
      End Sub
  
      Public Sub New(ByVal dblB As Double, ByVal strId As String)
          MyBase.New(CStr(dblB), CDbl(strId))
      End Sub
  
      Public Overrides Function GetBonus() As Double
          Return MyBase.GetBonus + (Sales - 2500) * 0.01
      End Function
  End Class
  </code></pre>
  
  <p>Main Form.vb</p>
  
  <pre><code>Option Explicit On
  Option Strict On
  Option Infer Off
  
  Public Class frmMain
  
      Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
          Me.Close()
      End Sub
  
      Private Sub txtSales_Enter(sender As Object, e As EventArgs) Handles txtSales.Enter
          txtSales.SelectAll()
      End Sub
  
      Private Sub txtSales_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtSales.KeyPress
          If (e.KeyChar &lt; "0" OrElse e.KeyChar &gt; "9") AndAlso e.KeyChar &lt;&gt; "." AndAlso e.KeyChar &lt;&gt; ControlChars.Back Then
              e.Handled = True
          End If
      End Sub
  
      Private Sub txtSales_TextChanged(sender As Object, e As EventArgs) Handles txtSales.TextChanged
          lblBonus.Text = String.Empty
      End Sub
  
      Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
          ' calculates and displays a bonus
  
  
  
          ' if the sales are over $2500, instantiate a PremiumBonus object
          ' and then calculate the bonus
          ' otherwise, instantiate a Bonus object and then calculate the bonus
          Dim myBonus As New Bonus
          Dim myPremiumBonus As New PremiumBonus
          Dim dblSales As Double
  
          If dblSales &gt; 2500 Then
              Double.TryParse(txtSales.Text, myPremiumBonus.Sales)
              dblSales = myPremiumBonus.GetBonus
          Else
              Double.TryParse(txtSales.Text, myBonus.Sales)
              dblSales = myBonus.GetBonus
          End If
  
          ' display the bonus
          lblBonus.Text = "ID:" &amp; (txtId.Text).PadRight(6) &amp; dblSales.ToString("C2")
      End Sub
  End Class
  </code></pre>