inveasy (project1) please use speaker notes for additional information!

16
InvEasy (Project1) Please use speaker notes for additional information!

Upload: mabel-perkins

Post on 29-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

InvEasy(Project1)

Please use speaker notes for additional information!

InvEasy - Project1InvEasy - Project1

InvEasy - Project1InvEasy - Project1

Defining variables that can be used in all subroutines.

InvEasy - Project 1InvEasy - Project 1

InvEasy - Project1InvEasy - Project1

Private Sub cmdAdd_Click() If optS1.Value = True Then wrkTotal1 = wrkTotal1 + Val(txtNumRec.Text) Else If optS2.Value = True Then wrkTotal2 = wrkTotal2 + Val(txtNumRec.Text) Else If optS3.Value = True Then wrkTotal3 = wrkTotal3 + Val(txtNumRec.Text) Else If optS4.Value = True Then wrkTotal4 = wrkTotal4 + Val(txtNumRec.Text) Else wrkResponse = MsgBox("Please select Style", 0, "Select Style") End If End If End If End IftxtNumRec.Text = ""txtNumRec.SetFocusoptS5.SetFocusEnd Sub

wrkTotal1, wrkTotal2, wrkTotal3 and wrkTotal4 were defined as String in the general area so they are available in all routines. Note also that wrkTotal1 is used when optS1 is selected and wrkTotal2 is used when optS2 is selected etc.

In previous examples, I used vbOkOnly in place of the 0 here. The accomplish the same thing.

txtNumRec is set to null which clears it out and it receives the focus which means that the cursor is set to this field. optS5 receives the focus and that means that it is the selected option. In fact, the txtNumRec.SetFocus is here just to show the code, it is overridden by the SetFocus statement beneath it. I actually handled the SetFocus in a different routine as you will see on later slides.

To accumulate a total, add the number to the accumulator and put the results back in the accumulator.

InvEasy - Project1InvEasy - Project1

InvEasy - Project1InvEasy - Project1

Private Sub cmdSum_Click() txtS1.Text = Format(wrkTotal1, "###0") txtS2.Text = Format(wrkTotal2, "###0") txtS3.Text = Format(wrkTotal3, "###0") txtS4.Text = Format(wrkTotal4, "###0") txtNumRec.SetFocusEnd Sub

When the Sum button is clicked, the sums that have been accumulated in the wrkTotal1 etc. accumulators are moved to the corresponding text boxes on the form. The formatting that is used suppresses leading zeros.

In this example, I clicked style 1 and entered 23. Then I clicked AddReceipt.

Next,I clicked style2 and entered 45. Then I clicked AddReceipt.

Finally, I clicked style1 again and entered 12. Then I clicked AddReceipt.

Now I wanted to see the totals so I clicked Sum and the code displayed the accumulated total for style1 which was 23 + 12, and the accumulated total for style2 which was the 45 that I entered. Since I entered no data for style3 or style4, 0 was displayed for these totals.

InvEasy - Project1InvEasy - Project1

Private Sub Form_Load() wrkTotal1 = 0 wrkTotal2 = 0 wrkTotal3 = 0 wrkTotal4 = 0End Sub

This code uses the Form_Load event which execute the Form_Load event procedure which initializes the four accumulators that were declared in the General - Declaratives area.

The initialization is to set each of the accumulators to 0.

InvEasy - Project1InvEasy - Project1

Private Sub optS1_Click() txtNumRec.SetFocusEnd Sub

Private Sub optS2_Click() txtNumRec.SetFocusEnd Sub

Private Sub optS3_Click() txtNumRec.SetFocusEnd Sub

Private Sub optS4_Click() txtNumRec.SetFocusEnd Sub

This the code that actually moves the focus to txtNumRec after one of the options has been clicked. It is a click event of the option button. When the option button is clicked the named click event procedure is executed. The sole function of the event procedure is to set the focus on the txtNumRec.

Style 1 is selected and 3 is entered for the number received.

The AddReceipt button is clicked.

Style 2 is selected and 12 is entered for the number received.

The AddReceipt button is clicked.

Style 1 is selected again and 24 is entered as the number received.

The AddReceipt button is clicked to add to the accumulator and reset.

Style 4 is selected and 100 is entered as the number received.

The AddReceipt button is clicked to add to the accumulator and reset.

Style 3 is selected and 50 is entered as the number received.

The AddReceipt button is clicked to add to the accumulator and reset.

Style 2is selected and 10 is entered as the number received.

The AddReceipt button is clicked to add to the accumulator and reset.

Sum is pressed and the result for each style is displayed. Style 1 has 3 and 24 which makes 27. Style 2 has 12 and 10 which makes 22. Style 3 has 50 and style 4 has 100.

InvEasy - ProjInv1InvEasy - ProjInv1

These 4 pictures of the form show the collection of data. After each data entry, the AddReceipt button was clicked.

When the Sum button is clicked, the accumulated totals are shown.

InvEasy - ProjInv2InvEasy - ProjInv2

In the first example, 12 was entered in # Received and AddReceipt was clicked. # Received is cleared and the amount shows in the Total Results for style 1. In the second example, the same processing puts 25 in Total Results for style 3.

In the third example, 100 was entered for style 1 which increased style 1 to 112 and in the fourth example, 15 was added for style 3.

Reset clears the totals but leaves the last style selection in place.