Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Newbie - Huge Select Case statement

Reply
Thread Tools

Newbie - Huge Select Case statement

 
 
Targa
Guest
Posts: n/a
 
      02-25-2004
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
%>


 
Reply With Quote
 
 
 
 
Bob Barrows
Guest
Posts: n/a
 
      02-25-2004
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"


 
Reply With Quote
 
 
 
 
Lance Wynn
Guest
Posts: n/a
 
      02-25-2004
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" <(E-Mail Removed)> wrote in message
news:uO9aM4%23%(E-Mail Removed)...
> 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
> %>
>
>



 
Reply With Quote
 
jenny mabe
Guest
Posts: n/a
 
      02-26-2004
On Wed, 25 Feb 2004 16:21:49 -0600, Targa <(E-Mail Removed)>
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
 
Reply With Quote
 
Targa
Guest
Posts: n/a
 
      02-26-2004
Perfect - Thanks!


"Bob Barrows" <(E-Mail Removed)> wrote in message
news:e$OpuE$%(E-Mail Removed)...
> 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"
>
>



 
Reply With Quote
 
Targa
Guest
Posts: n/a
 
      02-26-2004
Exactly what I was looking for!

Thanks!

"Lance Wynn" <(E-Mail Removed)> wrote in message
news:uQZvVH$%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:uO9aM4%23%(E-Mail Removed)...
> > 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
> > %>
> >
> >

>
>



 
Reply With Quote
 
Targa
Guest
Posts: n/a
 
      02-26-2004
Nope - All within a fixed height table inside <div></div> with overflow:
scroll


"jenny mabe" <(E-Mail Removed)> wrote in message
newspr3yaqzm0qafk40@localhost...
On Wed, 25 Feb 2004 16:21:49 -0600, Targa <(E-Mail Removed)>
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date variable doesn't retain its value in select case statement? Andy B ASP .Net 1 01-24-2009 11:57 AM
Memory error due to the huge/huge input file size tejsupra@gmail.com Python 3 11-20-2008 07:21 PM
Select Case statement with multiple varaibles microsoft.public.dotnet.languages.vb ASP General 1 12-11-2006 09:32 AM
how to case select with case-insensitive string ? Tee ASP .Net 3 06-23-2004 07:40 PM
Mimicking a SELECT/CASE statement using XSL Gadrin77 XML 2 05-05-2004 12:31 PM



Advertisments