' Project: Cookie Sales (Arrays) ' Programmer: Andy McCone ' Date: Winter 2008 'Description: This project will take sales from a girl scout troupe ' and store them in an array. Option Strict On Public Class mainForm 'Declare Array and counter Dim m_cookieSalesArrayDec(3) As Decimal Dim m_counterInteger As Integer Private Sub cookieButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cookieButton.Click 'Check to see if you are beyond the bounds of the array If m_counterInteger <= 3 Then 'Capture user input of Sales and place 'into Array (m_cookieSaleArray) m_cookieSalesArrayDec(m_counterInteger) = CDec(salesTextbox.Text) m_counterInteger += 1 Else MessageBox.Show("Sorry you can not add any more cookie sales", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Error) End If End Sub Private Sub totalSalesButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles totalSalesButton.Click 'Declare running total variable Dim totalDecimal As Decimal 'Move through each element in the array and add 'it to the running total (totalDecimal) For Each indSalesDecimal As Decimal In m_cookieSalesArrayDec totalDecimal += indSalesDecimal Next 'Display totalDecimal displayTextbox.Text = FormatCurrency(totalDecimal) End Sub End Class