Special Variables
Accumulator – a numeric variable used to store a value that gets added to
Flag – a variable that, when set true, signals the end of the loop
Look at the following examples.
| Example 1 |
Dim dblNumber As Double
Dim dblSum As Double
Do
dblNumber = InputBox("Enter a number (0 to end):")
If dblNumber > 0 Then
dblSum = dblSum + dblNumber
End If
Loop While dblNumber > 0
|
What does Example 1 do? What is the accumulator? What is the flag?
Class Exercise: Averager
We’re going to create a simple program used to average a set of numbers.
- Begin by designing the form.
- Use the names
lblCount, lblAverage, cmdEntry, cmdDonefor the controls on the form. - Add code to
cmdDone. - Add the code for
cmdEntry_Click.

| Averager Code |
Private Sub cmdDone_Click()
' end program
Unload frmMain
End Sub
Private Sub cmdEntry_Click() |
Assignment
The Prime Number assignment is due in one week. Start with an algorithm.
