CurveUptakeA = CurveUptakeA + CurveUptake(ect, monthNumber(year, month, startYear, s

  • Apologize first for a very rudimentary VBA question:


    (1) I came across the following coding for a custom function "CurveUptakeA"
    CurveUptakeA = CurveUptakeA + CurveUptake(ect, monthNumber(year, month, startYear, startMonth), 1, yearsToPeak, endY, peakTime, decayFactor)
    "CuveUptake" as a separate custom function is defined separately.


    Can anyone please help me understand what calculation the above equation is doing?


    (2) Where can I find some good examples of custom functions to generate s-curves?


    Thanks!

  • Re: CurveUptakeA = CurveUptakeA + CurveUptake(ect, monthNumber(year, month, startYear


    Quote

    I came across the following coding for a...


    You seem to have neglected to include the code - without that no one will be able to tell you exactly what it does

  • Re: CurveUptakeA = CurveUptakeA + CurveUptake(ect, monthNumber(year, month, startYear


    Thanks.
    The codes are pretty long so I was trying to keep the question short.
    My ultimate question is why the CurveUptakeA function is defined as CurveUptakeA (i.e. the very function itself) +....
    Please let me know if that makes sense. Thanks!

  • Re: CurveUptakeA = CurveUptakeA + CurveUptake(ect, monthNumber(year, month, startYear


    As written, CurveUptakeA is not a function but most likely a simple numeric variable.


    That line adds the return value from the Function CurveUptake to the current value of CurveUptakeA and stores the result back into CurveUptakeA

  • Re: CurveUptakeA = CurveUptakeA + CurveUptake(ect, monthNumber(year, month, startYear


    Thanks again.
    Please see below for the complete coding and let me know what I am missing. Thanks a lot!



  • Re: CurveUptakeA = CurveUptakeA + CurveUptake(ect, monthNumber(year, month, startYear


    The title of this thread (CurveUptakeA = CurveUptakeA + CurveUptake(ect, monthNumber(year, month, startYear) is explained in my last post [Note the references to CurveUptake & CurveUptakeA] - in the absence of a full explanation, that is what I assumed you meant.


    In VBA, values are returned from a function by assigning the value to a pseudo variable (you don't declare it, the compiler creates it) named the same as the function itself.


    For example, with everything else stripped out for clarity:


    Code
    Public Function Test() as Long
        Test = 5
    End Function


    If you don't assign a value to the 'variable' the function will always return 0

  • Re: CurveUptakeA = CurveUptakeA + CurveUptake(ect, monthNumber(year, month, startYear


    Apologies but I am confused.
    Let me try again and please bear with me.


    1) judging by the following code, I assume CurveUptakeA is a custom function. And I know it is because when I type "=CurveUptakeA" in a cell, a dialog box will pop up and I can input the parameters in order for the function to spit out a result.
    Function CurveUptakeA(ect As Double, year As Integer, startYear As Integer, startMonth As Integer, yearsToPeak As Double, endY As Double, _ Optional peakTime As Double = DEFAULT_PEAK, Optional decayFactor As Double = DEFAULT_DECAY) As Double


    2) If CurveUptakeA is indeed a custom function, then I'd like to understand the exact calculation it is doing.
    Judging by the following code, I just assumed (and sounds like I am wrong) the calculation for CurveUptakeA is defined as CurveUptakeA + Curveuptake
    CurveUptakeA = CurveUptakeA + CurveUptake(ect, monthNumber(year, month, startYear, startMonth), 1, yearsToPeak, endY, peakTime, decayFactor)


    I know I am missing something here but it looks like a circular calculation. Sorry I know this must be a really stupid question.


    Thanks a lot!

  • Re: CurveUptakeA = CurveUptakeA + CurveUptake(ect, monthNumber(year, month, startYear


    It's not a circular calculation. And I can't explain any more clearly than in my last post so I'm going to leave this for someone with a fresh pair of eyes....

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!