Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    if elseif then... number within range...

    Hi,

    I'm trying to code a calculation which checks if a number (number of days) is

    equal to 1
    bigger than 1 but lower than 8 (2 to 7)
    bigger than 7 but lower than 14 (8-13)
    bigger than 14

    there would be a response then depending on what category the result is...

    i had thought to do this with

    Code:
    <%if number = 1 then 
    	response.write("1")
    	elseif 1 < number < 8 then
    	response.write("more than one, less than 7")
    	elseif 7 < number < 14 then
    	response.write("more than 7, less than 14")
    	elseif number > 14 then
    	response.write("more than 14")
    	end if	
    	%>
    but that doesn't seem to do it. Hints and pointers welcome...
    and yes, i'm a novice :-)
    Last edited by haaid; 01-07-2009 at 01:46 PM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,853
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Code:
    elseif 1 < number < 8 then
    Don't know much about ASP, but I think the above should be
    Code:
    elseif 1 < number And  number  < 8 then
    (similarly for the other one)
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    haaid (01-07-2009)

  • #3
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    that solved it!

    Thank you.

  • #4
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Or...

    Code:
    select case true
    	case number = 1
    		' do stuff
    	case number > 1 and number < 8
    		' do stuff
    	case number > 7 and number < 14
    		' do stuff
    	case number > 14
    		' do stuff
    end select

  • #5
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    being ASP you may also want to cast your values as integers
    cint(number)

    ASP is picky about data types.


  •  

    Posting Permissions

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