J
jwebster1979
I am trying to buile a funtion that counts the number of days I will reach a
set dollar amount based off of what I am currently spending per day. The code
is as following:
Public Function DayAppropriatedAmountWillBeMet(BeginDate As Date,
CurrentSpent As Currency, AppropriatedAmount As Currency)
'Function will figure what day Appropriated Amount will be reached based off
current spending _
or when you will run out of money
Dim DaysPassed As Double
Dim M As Currency
Dim U As Currency
Dim MoneySpentPerDay As Currency
Dim Counter As Integer
DaysPassed = DateDiff("d", BeginDate, Now())
MoneySpentPerDay = CurrentSpent / DaysPassed
M = AppropriatedAmount
Counter = 0
U = CurrentSpent
Do Until U >= AppropriatedAmount
U = U + MoneySpentPerDay
Counter = Counter + 1
Loop
DayAppropriatedAmountWillBeMet = DateAdd("d", Counter, Date)
End Function
For some reason I keep getting an overflow error on Counter. my logic is
that this thing will loop U (that is incremented by MoneySpentPerDay) until
it is greater than my set amount of money or AppropriatedAmount. Counter is
counting the number of times it goes through this loop, but I always get the
overflow error that debugs to my Counter = Counter +1. I am not sure if I
need a different kind of loop or my loop can't handle doing that. PLEASE HELP
it is driving me nuts.
thanks
set dollar amount based off of what I am currently spending per day. The code
is as following:
Public Function DayAppropriatedAmountWillBeMet(BeginDate As Date,
CurrentSpent As Currency, AppropriatedAmount As Currency)
'Function will figure what day Appropriated Amount will be reached based off
current spending _
or when you will run out of money
Dim DaysPassed As Double
Dim M As Currency
Dim U As Currency
Dim MoneySpentPerDay As Currency
Dim Counter As Integer
DaysPassed = DateDiff("d", BeginDate, Now())
MoneySpentPerDay = CurrentSpent / DaysPassed
M = AppropriatedAmount
Counter = 0
U = CurrentSpent
Do Until U >= AppropriatedAmount
U = U + MoneySpentPerDay
Counter = Counter + 1
Loop
DayAppropriatedAmountWillBeMet = DateAdd("d", Counter, Date)
End Function
For some reason I keep getting an overflow error on Counter. my logic is
that this thing will loop U (that is incremented by MoneySpentPerDay) until
it is greater than my set amount of money or AppropriatedAmount. Counter is
counting the number of times it goes through this loop, but I always get the
overflow error that debugs to my Counter = Counter +1. I am not sure if I
need a different kind of loop or my loop can't handle doing that. PLEASE HELP
it is driving me nuts.
thanks