Help with Case function please

Author Message
Chodie

  • Total Posts : 4
  • Scores: 0
  • Reward points : 0
  • Joined: 11/28/2011
  • Status: offline
Help with Case function please Monday, November 28, 2011 4:40 AM (permalink)
0
[Helpful answer received] / [List Solutions Only]
I'm trying to make a script that will take user defined TERM and AMORT and find a rate with the entries. Right now it doesn't work at all.  The msgbox at the end never returns the correct rate.

Dim Term
Dim Amort
Dim Rate

Term=Inputbox("What is the Term length?")
Amort=Inputbox("What is the Amort length?")

Select Case Term AND Amort
Case 2, 2
Rate=.88
Case 2, 5
Rate=1.05
Case 2, 10
Rate=1.09
Case 2, 15
Rate=1.10
Case 2, 20
Rate=1.10
Case 2, 25
Rate=1.11
Case 3, 3
Rate=1.07
Case 3, 5
Rate=1.20
Case 3, 10
Rate=1.26
Case 3, 15
Rate=1.28
Case 3, 20
Rate=1.28
Case 3, 25
Rate=1.29
End Select

msgBox Rate



Entering 2 for TERM and 2 for AMORT will return a msgbox with .88 inside but if I enter 2 for TERM and 5 for AMORT a msgbox with nothing inside will show.

I've also tried using & instead of AND but with no avail.
<message edited by Chodie on Monday, November 28, 2011 5:06 AM>
 
#1
    ebgreen

    • Total Posts : 8227
    • Scores: 98
    • Reward points : 0
    • Joined: 7/12/2005
    • Status: offline
    Re:Help with Case function please Monday, November 28, 2011 5:09 AM (permalink)
    0
    [This post was marked as helpful]
    First off, Select-Case only works with one variable. So personally I would use a dictionary of dictionaries:
     
    Option Explicit
    Dim dicTerm :Set dicTerm = CreateObject("Scripting.Dictionary")
    Dim Amort
    Dim Rate
    Dim Term
    Term=Inputbox("What is the Term length?")
    Amort=Inputbox("What is the Amort length?") 
    Set dicTerm("2") = CreateObject("Scripting.Dictionary")
    dicTerm("2")("2") = .88
    dicTerm("2")("5") = 1.05
    dicTerm("2")("10") = 1.09
    dicTerm("2")("15") = 1.10
    dicTerm("2")("20") = 1.10
    dicTerm("2")("25") = 1.11
    Set dicTerm("3") = CreateObject("Scripting.Dictionary")
    dicTerm("3")("3") = 1.07
    dicTerm("3")("5") = 1.20
    dicTerm("3")("10") = 1.26
    dicTerm("3")("15") = 1.28
    dicTerm("3")("20") = 1.28
    dicTerm("3")("25") = 1.29
    Rate = dicTerm(Term)(Amort)
    msgBox Rate
     
    "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
    Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
    http://www.visualbasicscript.com/m_47117/tm.htm
     
    #2
      Chodie

      • Total Posts : 4
      • Scores: 0
      • Reward points : 0
      • Joined: 11/28/2011
      • Status: offline
      Re:Help with Case function please Monday, November 28, 2011 5:17 AM (permalink)
      0
      This is amazing.  Thank you so much.
       
      #3

        Online Bookmarks Sharing: Share/Bookmark

        Jump to:

        Current active users

        There are 0 members and 1 guests.

        Icon Legend and Permission

        • New Messages
        • No New Messages
        • Hot Topic w/ New Messages
        • Hot Topic w/o New Messages
        • Locked w/ New Messages
        • Locked w/o New Messages
        • Read Message
        • Post New Thread
        • Reply to message
        • Post New Poll
        • Submit Vote
        • Post reward post
        • Delete my own posts
        • Delete my own threads
        • Rate post

        2000-2012 ASPPlayground.NET Forum Version 3.9