Привет всем, кто-нибудь может мне помочь с выполнением долларов в этой функции.Это делает изменения просто отлично, но делает все суммы обратно в смену, и я хочу большие счета (1, 5, 10 и 20 долларов) в долларах и изменение Q / D /N / P.
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)
Любая помощь будет отличной!: o)
Обновление решено
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
Дэвид