Newbie - Huge Select Case statement

Discussion in 'ASP General' started by Targa, Feb 25, 2004.

  1. Targa

    Targa Guest

    My plan is to use select case to position style elements in a table but
    since I have to allow for every minute of the day, the select case statement
    will be quite huge. See code below.
    Is there a better/more efficient way to do this?

    Thanks!

    <%
    MySchedule=rs("MyStartTime")
    SELECT CASE MySchedule

    Case "12:00 AM"
    Response.write "style=top: 19px;"

    Case "12:01 AM"
    Response.write "style=top: 20px;"

    Case "12:02 AM"
    Response.write "style=top: 21px;"

    Case "12:03 AM"
    Response.write "style=top: 22px;"

    Case "12:04 AM"
    Response.write "style=top: 23px;"

    Case "12:05 AM"
    Response.write "style=top: 24px;"

    Case "12:06 AM"
    Response.write "style=top: 25px;"

    '***AND SO ON****

    Case "11:59 PM"
    Response.write "style=top: 1458px;"

    END SELECT
    %>
     
    Targa, Feb 25, 2004
    #1
    1. Advertising

  2. Targa

    Bob Barrows Guest

    Targa wrote:
    > My plan is to use select case to position style elements in a table
    > but since I have to allow for every minute of the day, the select
    > case statement will be quite huge. See code below.
    > Is there a better/more efficient way to do this?
    >
    > Thanks!
    >
    > <%
    > MySchedule=rs("MyStartTime")
    > SELECT CASE MySchedule
    >
    > Case "12:00 AM"
    > Response.write "style=top: 19px;"
    >
    > Case "12:01 AM"
    > Response.write "style=top: 20px;"
    >

    <snip>

    I don't know about you, but I see a pattern: the pixels go up one for every
    minute. That seems to suggest a formula... Doesn't it?

    How about:
    Dim iTop, dSched
    dSched = CDate(rs("MyStartTime"))
    iTop = 19 + DateDiff("n",#12:00 AM#, dSched)
    Response.write "style=""top: " & iTop & "px"""

    HTH,
    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows, Feb 25, 2004
    #2
    1. Advertising

  3. Targa

    Lance Wynn Guest

    Hi,
    Perhaps you could calculate the minute difference between the current time,
    and 12:00 midnight, and then add 19 to it?


    <%
    MySchedule=rs("MyStartTime")
    topOffset = Datediff("n","12:00 am", MySchedule) + 19
    Response.write "style=top: " & topOffset & "px;"
    %>

    (I haven't tested this, but it should work.)

    Lance




    "Targa" <> wrote in message
    news:uO9aM4%23%...
    > My plan is to use select case to position style elements in a table but
    > since I have to allow for every minute of the day, the select case

    statement
    > will be quite huge. See code below.
    > Is there a better/more efficient way to do this?
    >
    > Thanks!
    >
    > <%
    > MySchedule=rs("MyStartTime")
    > SELECT CASE MySchedule
    >
    > Case "12:00 AM"
    > Response.write "style=top: 19px;"
    >
    > Case "12:01 AM"
    > Response.write "style=top: 20px;"
    >
    > Case "12:02 AM"
    > Response.write "style=top: 21px;"
    >
    > Case "12:03 AM"
    > Response.write "style=top: 22px;"
    >
    > Case "12:04 AM"
    > Response.write "style=top: 23px;"
    >
    > Case "12:05 AM"
    > Response.write "style=top: 24px;"
    >
    > Case "12:06 AM"
    > Response.write "style=top: 25px;"
    >
    > '***AND SO ON****
    >
    > Case "11:59 PM"
    > Response.write "style=top: 1458px;"
    >
    > END SELECT
    > %>
    >
    >
     
    Lance Wynn, Feb 25, 2004
    #3
  4. Targa

    jenny mabe Guest

    On Wed, 25 Feb 2004 16:21:49 -0600, Targa <>
    wrote:

    > Case "11:59 PM"
    > Response.write "style=top: 1458px;"


    Just wondering, but isnt this going to position the element well off the
    screen of most users?


    Jenny
     
    jenny mabe, Feb 26, 2004
    #4
  5. Targa

    Targa Guest

    Perfect - Thanks!


    "Bob Barrows" <> wrote in message
    news:e$OpuE$%...
    > Targa wrote:
    > > My plan is to use select case to position style elements in a table
    > > but since I have to allow for every minute of the day, the select
    > > case statement will be quite huge. See code below.
    > > Is there a better/more efficient way to do this?
    > >
    > > Thanks!
    > >
    > > <%
    > > MySchedule=rs("MyStartTime")
    > > SELECT CASE MySchedule
    > >
    > > Case "12:00 AM"
    > > Response.write "style=top: 19px;"
    > >
    > > Case "12:01 AM"
    > > Response.write "style=top: 20px;"
    > >

    > <snip>
    >
    > I don't know about you, but I see a pattern: the pixels go up one for

    every
    > minute. That seems to suggest a formula... Doesn't it?
    >
    > How about:
    > Dim iTop, dSched
    > dSched = CDate(rs("MyStartTime"))
    > iTop = 19 + DateDiff("n",#12:00 AM#, dSched)
    > Response.write "style=""top: " & iTop & "px"""
    >
    > HTH,
    > Bob Barrows
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >
     
    Targa, Feb 26, 2004
    #5
  6. Targa

    Targa Guest

    Exactly what I was looking for!

    Thanks!

    "Lance Wynn" <> wrote in message
    news:uQZvVH$%...
    > Hi,
    > Perhaps you could calculate the minute difference between the current

    time,
    > and 12:00 midnight, and then add 19 to it?
    >
    >
    > <%
    > MySchedule=rs("MyStartTime")
    > topOffset = Datediff("n","12:00 am", MySchedule) + 19
    > Response.write "style=top: " & topOffset & "px;"
    > %>
    >
    > (I haven't tested this, but it should work.)
    >
    > Lance
    >
    >
    >
    >
    > "Targa" <> wrote in message
    > news:uO9aM4%23%...
    > > My plan is to use select case to position style elements in a table but
    > > since I have to allow for every minute of the day, the select case

    > statement
    > > will be quite huge. See code below.
    > > Is there a better/more efficient way to do this?
    > >
    > > Thanks!
    > >
    > > <%
    > > MySchedule=rs("MyStartTime")
    > > SELECT CASE MySchedule
    > >
    > > Case "12:00 AM"
    > > Response.write "style=top: 19px;"
    > >
    > > Case "12:01 AM"
    > > Response.write "style=top: 20px;"
    > >
    > > Case "12:02 AM"
    > > Response.write "style=top: 21px;"
    > >
    > > Case "12:03 AM"
    > > Response.write "style=top: 22px;"
    > >
    > > Case "12:04 AM"
    > > Response.write "style=top: 23px;"
    > >
    > > Case "12:05 AM"
    > > Response.write "style=top: 24px;"
    > >
    > > Case "12:06 AM"
    > > Response.write "style=top: 25px;"
    > >
    > > '***AND SO ON****
    > >
    > > Case "11:59 PM"
    > > Response.write "style=top: 1458px;"
    > >
    > > END SELECT
    > > %>
    > >
    > >

    >
    >
     
    Targa, Feb 26, 2004
    #6
  7. Targa

    Targa Guest

    Nope - All within a fixed height table inside <div></div> with overflow:
    scroll


    "jenny mabe" <> wrote in message
    news:eek:pr3yaqzm0qafk40@localhost...
    On Wed, 25 Feb 2004 16:21:49 -0600, Targa <>
    wrote:

    > Case "11:59 PM"
    > Response.write "style=top: 1458px;"


    Just wondering, but isnt this going to position the element well off the
    screen of most users?


    Jenny
     
    Targa, Feb 26, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tee
    Replies:
    3
    Views:
    7,859
    Herfried K. Wagner [MVP]
    Jun 23, 2004
  2. Gadrin77
    Replies:
    2
    Views:
    679
    Andy Fish
    May 5, 2004
  3. Replies:
    3
    Views:
    522
  4. Lakshmi Narayanan.R

    "Case 1 To 5" in Select case, giving Error!!. Why?

    Lakshmi Narayanan.R, Mar 2, 2005, in forum: ASP General
    Replies:
    10
    Views:
    361
    Bob Barrows [MVP]
    Mar 4, 2005
  5. aa
    Replies:
    14
    Views:
    334
Loading...

Share This Page