Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "InvEasy (Project1) Please use speaker notes for additional information!"— Presentation transcript:

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

2 InvEasy - Project1

3 Defining variables that can be used in all subroutines.

4 InvEasy - Project 1

5 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 txtNumRec.Text = "" txtNumRec.SetFocus optS5.SetFocus End 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.

6 InvEasy - Project1

7 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.SetFocus End 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.

8 InvEasy - Project1 Private Sub Form_Load() wrkTotal1 = 0 wrkTotal2 = 0 wrkTotal3 = 0 wrkTotal4 = 0 End 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.

9 InvEasy - Project1 Private Sub optS1_Click() txtNumRec.SetFocus End Sub Private Sub optS2_Click() txtNumRec.SetFocus End Sub Private Sub optS3_Click() txtNumRec.SetFocus End Sub Private Sub optS4_Click() txtNumRec.SetFocus End 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.

10 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.

11 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.

12 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.

13 InvEasy - ProjInv1

14 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.

15 InvEasy - ProjInv2

16 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.


Download ppt "InvEasy (Project1) Please use speaker notes for additional information!"

Similar presentations


Ads by Google