Private Sub cmdCountPledges_Click()
Dim intCountArray(5), intTotal, intPledgeValue As Integer
Dim intIndex, intNumberOfPledges, intCrossCheckTotal As Integer
intTotal = 0
intNumberOfPledges = 0
intCrossCheckTotal = 0
intPledgeValue = Val(InputBox("Enter Pledge value (1, 2, 3, 4, 5)", _
"Integer Value", "0"))
Do While intPledgeValue <> 0
intCountArray(intPledgeValue) = intCountArray(intPledgeValue) + 1
intTotal = intTotal + intPledgeValue
intNumberOfPledges = intNumberOfPledges + 1
intPledgeValue = Val(InputBox("Enter Pledge value (1, 2, 3, 4, 5)",
_
"Integer Value", "0"))
Loop
For intIndex = 1 To 5
intCrossCheckTotal = intCrossCheckTotal + (intIndex * intCountArray
(intIndex))
MsgBox "Number of $" & intIndex & " donors is " &
intCountArray(intIndex), _
vbOKOnly, "Donor Count"
Next intIndex
If intCrossCheckTotal = intTotal Then
MsgBox "Total Amount of Pledges is: " & intTotal, _
vbOKOnly, "Total Pledges"
Else
MsgBox "Pledge Total does not cross-check!", , "Error"
End If
End Sub |
|