+ Reply to Thread
Results 1 to 6 of 6

Help Programming Limit Constraint

  1. #1
    Registered User
    Join Date
    07-08-2006
    Posts
    3

    Help Programming Limit Constraint

    Hey All,

    Just a quick question. I have a function called IndexSim and would like to set an IF statement so that it is inbetween two values, UpperRange and LowerRange. I have used the following:


    Please Login or Register  to view this content.
    Is this correct, as I don't think it produces the outcome I want?

    Please advise,

    Many thanks,

    Suz84

  2. #2
    Bob Phillips
    Guest

    Re: Help Programming Limit Constraint

    You are showing code that suggests that IndexSim is an array, whereas you
    call it a function. They are very different (although a function could
    return an array), so how about showing the indexSim code.

    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "Suz84" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hey All,
    >
    > Just a quick question. I have a function called -IndexSim- and would
    > like to set an IF statement so that it is inbetween two values,
    > -UpperRange- and -LowerRange-. I have used the following:
    >
    >
    >
    > Code:
    > --------------------
    >
    > If IndexSim(Cnt) >= LowerRange And IndexSim(Cnt) <= UpperRange Then
    >
    > --------------------
    >
    > Is this correct, as I don't think it produces the outcome I want?
    >
    > Please advise,
    >
    > Many thanks,
    >
    > Suz84
    >
    >
    > --
    > Suz84
    > ------------------------------------------------------------------------
    > Suz84's Profile:

    http://www.excelforum.com/member.php...o&userid=36189
    > View this thread: http://www.excelforum.com/showthread...hreadid=567415
    >




  3. #3
    Registered User
    Join Date
    07-08-2006
    Posts
    3
    IndexSim is simply a value to a function, that is what I meant to say:

    Please Login or Register  to view this content.
    It produces a value which I would like to know if it is within the constraint above.

  4. #4
    Tom Ogilvy
    Guest

    RE: Help Programming Limit Constraint

    I wouldn't call it twice

    Dim idex as Long
    idex = IndexSim(cnt)
    if idex < lowerRange then
    idex = lowerRange
    elseif idex > upperRange then
    idex = UpperRange
    end if

    maybe what you are looking for.

    If you just want to validate the result, then your approach is correct.


    Dim idex as Long
    idex = IndexSim(cnt)
    If idex >= LowerRange And idex <= UpperRange Then
    Msgbox "within bounds"
    else
    Msgbox "Outside of bounds"
    End if

    If you mean within the function

    Public Function IdexSim(cnt as Long)
    Const UpperRange as Long = 100
    Const LowerRange as Long = 50
    if cnt > UpperRange then
    IdexSim = UpperRange
    elseif cnt < LowerRange then
    IdexSim = LowerRange
    else
    IdexSim = cnt
    end if
    End Function



    --
    Regards,
    Tom Ogilvy


    "Suz84" wrote:

    >
    > Hey All,
    >
    > Just a quick question. I have a function called -IndexSim- and would
    > like to set an IF statement so that it is inbetween two values,
    > -UpperRange- and -LowerRange-. I have used the following:
    >
    >
    >
    > Code:
    > --------------------
    >
    > If IndexSim(Cnt) >= LowerRange And IndexSim(Cnt) <= UpperRange Then
    >
    > --------------------
    >
    > Is this correct, as I don't think it produces the outcome I want?
    >
    > Please advise,
    >
    > Many thanks,
    >
    > Suz84
    >
    >
    > --
    > Suz84
    > ------------------------------------------------------------------------
    > Suz84's Profile: http://www.excelforum.com/member.php...o&userid=36189
    > View this thread: http://www.excelforum.com/showthread...hreadid=567415
    >
    >


  5. #5
    Tom Ogilvy
    Guest

    Re: Help Programming Limit Constraint

    What you show would indicate IndexSim is an array

    Dim IndexSim(1 to 20) as Double

    for cnt = 1 to 20
    ' code that changes inputs to gBmProcess
    IndexSim(cnt) = IndexSim(Cnt) = gBmProcess(Kt, r, q, Vol, TMat - TNow)
    if indexSim(cnt) >= LowerRange and IndexSim(cnt) <= UpperRange then
    msgbox cnt & ". " & IndexSim(cnt) " & is within bounds"
    else
    msgbox cnt & ". " & indexSim(cnt) & " is out of bounds"
    end if
    Next

    --
    Regards,
    Tom Ogilvy

    "Suz84" wrote:

    >
    > IndexSim is simply a value to a function, that is what I meant to say:
    >
    >
    > Code:
    > --------------------
    >
    > IndexSim(Cnt) = gBmProcess(Kt, r, q, Vol, TMat - TNow)
    >
    > --------------------
    >
    >
    > It produces a value which I would like to know if it is within the
    > constraint above.
    >
    >
    > --
    > Suz84
    > ------------------------------------------------------------------------
    > Suz84's Profile: http://www.excelforum.com/member.php...o&userid=36189
    > View this thread: http://www.excelforum.com/showthread...hreadid=567415
    >
    >


  6. #6
    Bob Phillips
    Guest

    Re: Help Programming Limit Constraint

    and I repeat what I said previously.

    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "Tom Ogilvy" <[email protected]> wrote in message
    news:[email protected]...
    > What you show would indicate IndexSim is an array
    >
    > Dim IndexSim(1 to 20) as Double
    >
    > for cnt = 1 to 20
    > ' code that changes inputs to gBmProcess
    > IndexSim(cnt) = IndexSim(Cnt) = gBmProcess(Kt, r, q, Vol, TMat - TNow)
    > if indexSim(cnt) >= LowerRange and IndexSim(cnt) <= UpperRange then
    > msgbox cnt & ". " & IndexSim(cnt) " & is within bounds"
    > else
    > msgbox cnt & ". " & indexSim(cnt) & " is out of bounds"
    > end if
    > Next
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Suz84" wrote:
    >
    > >
    > > IndexSim is simply a value to a function, that is what I meant to say:
    > >
    > >
    > > Code:
    > > --------------------
    > >
    > > IndexSim(Cnt) = gBmProcess(Kt, r, q, Vol, TMat - TNow)
    > >
    > > --------------------
    > >
    > >
    > > It produces a value which I would like to know if it is within the
    > > constraint above.
    > >
    > >
    > > --
    > > Suz84
    > > ------------------------------------------------------------------------
    > > Suz84's Profile:

    http://www.excelforum.com/member.php...o&userid=36189
    > > View this thread:

    http://www.excelforum.com/showthread...hreadid=567415
    > >
    > >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1