Hey everyone, could anyone help me out with doing the Dollars in this function. It does the change just fine but it does all of the amount back in change and i want to big bills ($1,$5,$10, & $20)'s in dollars and the change in Q/D/N/P's.
Dim Quarters As Integer
Dim Dimes As Integer
Dim Nickels As Integer
Dim Pennies As Integer
Sub GetChange(ByVal Amount As Currency, ByRef Quarters As Integer, ByRef Dimes As Integer, ByRef Nickels As Integer, ByRef Pennies As Integer)
Dim Cents As Integer
Cents = Amount * 100
Quarters = Cents \ 25
Cents = Cents Mod 25
Dimes = Cents \ 10
Cents = Cents Mod 10
Nickels = Cents \ 5
Pennies = Cents Mod 5
End Sub
Call GetChange(5.56, Quarters, Dimes, Nickels, Pennies)
Any help would be awesome! :o)
Update, solved
Private Sub theUSChange(Amount)
Dim USCurrency(9) As Currency
Dim USCurrencyNames(9) As Currency
Dim Amount As Currency
Dim Result As Currency
Dim I As Integer
USCurrencyNames(0) = " Pennies: "
USCurrency(0) = 0.01
USCurrencyNames(1) = " Dimes: "
USCurrency(1) = 0.05
USCurrencyNames(2) = " Nickles: "
USCurrency(2) = 0.1
USCurrencyNames(3) = "Quarters: "
USCurrency(3) = 0.25
USCurrencyNames(4) = " $1: "
USCurrency(4) = 1
USCurrencyNames(5) = " $5: "
USCurrency(5) = 5
USCurrencyNames(6) = " $10: "
USCurrency(6) = 10
USCurrencyNames(7) = " $20: "
USCurrency(7) = 20
USCurrencyNames(8) = " $50: "
USCurrency(8) = 50
USCurrencyNames(9) = " $100: "
USCurrency(9) = 100
For I = UBound(USCurrency) To LBound(USCurrency) Step -1
Do While Amount >= USCurrency(I)
Amount = Amount - USCurrency(I)
Result = Result + 1
Loop
Debug.Print(USCurrencyNames(I) & Result)
Result = 0
Next
End Sub
call theUSChange(5.77)
OUTPUT:
$100: 0
$50: 0
$20: 0
$10: 0
$5: 1
$1: 0
Quarters: 3
Nickles: 0
Dimes: 0
Pennies: 2
David