Ok here is what I am doing. I have to develop a program that determines how much a salesperson makes. Here is the following instructions:

A salesperson earns a weekly base salary plus a commission when sales are at or above quota. Create a project that allows the user to input the weekly sales, and teh salesperson name, calculates the commission, and displays summary information.

Write a function procedure to calculate the commission. The function must compare sales to the quota. When the sales are equal to or greater than the quota, calculate the commission by multiplying sales by the commission rae. Each salesperons receives the base pay plus the commission (if one has been earned).

I am having trouble developing a function. I have most of the code for the calculate button coded. Here is what I have so far. When the calculate button is pushed it must output the commission(if one is earned), total sales adn the total pay earned.

VB Code:
  1. 'Program Name       Chapter5ExtraCredit
  2. 'Programmer         Chad R. Bruckman
  3. 'Date               10/15/2006
  4. 'Description        A salesperson earns a weekly base salary
  5. '                   plus a commission when sales weekly sales
  6. '                   are at or above quota.
  7. Public Class salesForm
  8.     'Declare module-level variables for summary information.
  9.     Dim totalCommissionDecimal, totalsalesDecimal, totalpayDecimal As Decimal
  10.     Dim salesCountInteger As Integer
  11.  
  12.     'Declare constants
  13.  
  14.     Const QUOTA_Decimal = 1000
  15.     Const COMMISSION_RATE_Decimal = 0.15F
  16.     Const BASE_PAY_Decimal = 250D
  17.  
  18.     Private Sub calculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculateButton.Click
  19.         'Calculate and display the current amounts and add to totals.
  20.         Dim totalPayDecimal, totalAmountDecimal As Decimal
  21.  
  22.         With Me
  23.             'Calculate the total pay.
  24.             With Me
  25.                 Try
  26.                     salesCountInteger = Integer.Parse(.weeklySalesTextBox.Text)
  27.  
  28.                     totalPayDecimal = FindCommission(BASE_PAY_Decimal)
  29.  
  30.  
  31.                     .commissionTextBox.Text = totalCommissionDecimal.ToString("N")
  32.                     .totalSalesTextBox.Text = salesCountInteger.ToString("D")
  33.                     .totalPayTextBox.Text = totalPayDecimal.ToString("C")
  34.                 Catch quantityException As FormatException
  35.                     MessageBox.Show("Input must be numeric.", "Data Entry Error", _
  36.                     MessageBoxButtons.OK, MessageBoxIcon.Information)
  37.                     With .weeklySalesTextBox
  38.                         .Focus()
  39.                         .SelectAll()
  40.                     End With
  41.                 End Try
  42.             End With
  43.         End With
  44.     End Sub
  45.  
  46.     Private Function FindCommission(ByVal totalCommissionDecimal As Decimal) As Decimal
  47.         If QUOTA_Decimal >= salesCountInteger Then
  48.             Return salesCountInteger * COMMISSION_RATE_Decimal
  49.         Else
  50.             Return BASE_PAY_Decimal
  51.         End If
  52.     End Function
  53.  
  54.  
  55. End Class