Dim Counts(5) As Integer = {0,0,0,0,0}
Dim tmpValue as Integer
Dim tmpMessage as string
Dim tmpTest as Boolean
' Initialise
tmpMessage = ""
tmpTest = false
tmpMessage = ""
tmpValue = Choice
'Process
Do
'// $100
If tmpValue > 100 Then
counts(0) = counts(0) + 1
tmpValue = tmpValue - 100
'
ElseIf tmpValue > 50 Then
counts(1) = counts(1) + 1
tmpValue = tmpValue - 50
'// $20
ElseIf tmpValue > 20 Then
counts(2) = counts(2) + 1
tmpValue = tmpValue - 20
'
ElseIf tmpValue > 10 Then
counts(3) = counts(3) + 1
tmpValue = tmpValue - 10
'// $5
ElseIf tmpValue > 5 Then
counts(4) = counts(4) + 1
tmpValue = tmpValue - 5
'
ElseIf tmpValue > 1 Then
counts(5) = counts(5) + 1
tmpValue = tmpValue - 1
End If
Loop Until tmpValue < 1
'Finish
If Counts(0) <= 10 Then
If Counts(1) <= 10 Then
If Counts(2) <= 10 Then
If Counts(3) <= 10 Then
If Counts(4) <= 10 Then
If Counts(5) <= 10 Then
tmpMessage & "This can be given in:" & vbcrlf
tmpMessage = tmpMessage & " " & counts(0) & " $100 notes" & vbcrlf
tmpMessage = tmpMessage & " " & counts(1) & " $50 notes" & vbcrlf
tmpMessage = tmpMessage & " " & counts(2) & " $20 notes" & vbcrlf
tmpMessage = tmpMessage & " " & counts(3) & " $10 notes" & vbcrlf
tmpMessage = tmpMessage & " " & counts(4) & " $1 notes"
Else
tmpMessage = "Not enough $1 notes remaining in ATM"
End If
Else
tmpMessage = "Not enough $5 notes remaining in ATM"
End If
Else
tmpMessage = "Not enough $10 notes remaining in ATM"
End If
Else
tmpMessage = "Not enough $20 notes remaining in ATM"
End If
Else
tmpMessage = "Not enough $100 notes remaining in ATM"
End If
End If
msgbox(tmpmessage)