I am working on an exercise from the Deitel "Simply" Visual Basic book. p.379. Here is the objective :
to create an application that determines how many salespeople earned salaries in each range (the reanges are 0-99, 100-199, 200-299 etc).
create a string array and initialize it to contain the salary ranges
create an array that represents the number of salaries in each range. this is a decimal array to store_the number of employees who earn salaries in each range.
create an event handlers for a calculate button: obtain user input from an Enter Sales Text Box.
calculate the commission due and add to the base salary.
Increment the element in array decSalaries that corresponds to the the employees salary in the Total Salary : label
if you would please take a look at the code I have so far written this morning, you will see that (I think) I have achieved most of the objectives. I am able to calculate the
commission due and display it correctly.
Public Class FrmSalarySurvey
Inherits System.Windows.Forms.Form
'string array stores the salary ranges
Dim m_strSalaryRanges As String() = New String() _
{"200 - 299", "300 - 399", "400 - 499", "500 - 599", "600 - 699", "700 - 799", _
"800 - 899", "900 - 999", "1000 - "}
'an empty array to store how many employees earn each salary range
Dim m_decSalaries As Decimal() = New Decimal(m_strSalaryRanges.GetUpperBound(0)) {}
Dim m_intCounter As Integer = 1 ' number of salaries
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim dblgrossSales As Double
Dim dblcommission As Double = 0.09
Dim dblSalary As Double
Dim dblBaseSalary As Double = 200
dblgrossSales = Val(txtInputSales.Text) ' assigning a property's value to a variable
dblSalary = dblgrossSales * dblcommission + dblBaseSalary 'calculate the total salary due
lblTotalSalary.Text = Convert.ToString(dblSalary) 'returning the variable to a property as a String
'increment the element in m_decSalaries array that corresponds to the employee's salary range
m_intCounter += 1
End Sub
End Class ' FrmSalarySurvey
My problem is now this : how to "increment the element in array decSalaries that correspond to the employee's saalary range"
I am supposed to create a loop , I heard yesterday from a friend who wont tell me anymore !
Thanks for any tips.
Dan Ashcroft.
Enter your message below
Sign in or Join us (it's free).