Help Turn IfThen mess into loop!

Discussion in 'ASP General' started by Jake, Jan 28, 2005.

  1. Jake

    Jake Guest

    OK Ive got a huge amount of If Then statements that Im sure can be stripped
    way down to a simple loop or two but Im not familiar enough with them to
    know where to start.
    Basically this is a truck scheduling application which builds a layer for
    each schedule of each truck from Monday thru Sunday.
    Below are the statements I have so far and I need to go up to 20 trucks. I
    think you'll be able to tell what Im trying to do.
    You'll notice from 3 trucks on, the layer widths are the same.

    Can someone guide me on how I can convert this to a loop to cut down the
    amount of code?

    Thanks in advance!

    <% '############## SET DIV WIDTH DETERMINED BY TRUCK COUNT
    If myRS("TruckTotal") = 1 then
    response.write "132"
    ElseIf myRS("TruckTotal") = 2 then
    response.write "67"
    ElseIf myRS("TruckTotal") = 3 then
    response.write "35"
    ElseIf myRS("TruckTotal") > 3 then
    response.write "35"
    End If
    %>px;
    <%
    '############## Grab Day, Truck # and position div horizontally
    #############
    '#################################### 1 Truck ###
    '###Monday
    If myRS("TruckTotal") = 1 then
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 1 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 42px;"
    end if
    end if
    '###Tuesday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 2 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 173px;"
    end if
    end if
    '###Wednesday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 3 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 304px;"
    end if
    end if
    '###Thursday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 4 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 435px;"
    end if
    end if
    '###Friday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 5 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 566px;"
    end if
    end if
    '###Saturday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 6 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 697px;"
    end if
    end if
    '###Sunday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 7 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 828px;"
    end if
    end if
    end if

    '############################ 2 Trucks ###
    '###Monday
    If myRS("TruckTotal") = 2 then
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 1 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 42px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 108px;"
    end if
    end if
    '###Tuesday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 2 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 174px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 240px;"
    end if
    end if
    '###Wednesday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 3 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 306px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 372px;"
    end if
    end if
    '###Thursday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 4 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 438px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 504px;"
    end if
    end if
    '###Friday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 5 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 570px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 636px;"
    end if
    end if
    '###Saturday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 6 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 702px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 768px;"
    end if
    end if
    '###Sunday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 7 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 834px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 900px;"
    end if
    end if
    end if

    '######################### 3 Trucks ###
    '###Monday
    If myRS("TruckTotal") = 3 then
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 1 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 42px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 76px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 110px;"
    end if
    end if
    '###Tuesday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 2 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 144px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 178px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 212px;"
    end if
    end if
    '###Wednesday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 3 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 246px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 280px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 314px;"
    end if
    end if
    '###Thursday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 4 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 348px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left:382px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 416px;"
    end if
    end if
    '###Friday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 5 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 450px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 484px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 518px;"
    end if
    end if
    '###Saturday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 6 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 552px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 586px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 620px;"
    end if
    end if
    '###Sunday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 7 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 654px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 688px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 722px;"
    end if
    end if
    end if

    '######################### 4 Trucks ###
    '###Monday
    If myRS("TruckTotal") = 4 then
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 1 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 42px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 76px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 110px;"
    elseif myRS2("TruckIndex")="4" then
    response.write "left: 144px;"

    end if
    end if
    '###Tuesday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 2 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 178px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 212px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 246px;"
    elseif myRS2("TruckIndex")="4" then
    response.write "left: 280px;"
    end if
    end if
    '###Wednesday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 3 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 314px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 348px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 382px;"
    elseif myRS2("TruckIndex")="4" then
    response.write "left: 416px;"
    end if
    end if
    '###Thursday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 4 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 450px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left:484px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 518px;"
    elseif myRS2("TruckIndex")="4" then
    response.write "left: 552px;"
    end if
    end if
    '###Friday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 5 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 586px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 620px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 654px;"
    elseif myRS2("TruckIndex")="4" then
    response.write "left: 688px;"
    end if
    end if
    '###Saturday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 6 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 722px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 756px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 790px;"
    elseif myRS2("TruckIndex")="4" then
    response.write "left: 824px;"
    end if
    end if
    '###Sunday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 7 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 858px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 892px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 926px;"
    elseif myRS2("TruckIndex")="4" then
    response.write "left: 960px;"
    end if
    end if
    end if

    '######################### 5 Trucks ###
    '###Monday
    If myRS("TruckTotal") = 5 then
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 1 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 42px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 76px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 110px;"
    elseif myRS2("TruckIndex")="4" then
    response.write "left: 144px;"
    elseif myRS2("TruckIndex")="5" then
    response.write "left: 178px;"

    end if
    end if
    '###Tuesday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 2 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 212px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 246px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 280px;"
    elseif myRS2("TruckIndex")="4" then
    response.write "left: 314px;"
    elseif myRS2("TruckIndex")="5" then
    response.write "left: 348px;"
    end if
    end if
    '###Wednesday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 3 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 382px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 416px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 450px;"
    elseif myRS2("TruckIndex")="4" then
    response.write "left: 484px;"
    elseif myRS2("TruckIndex")="5" then
    response.write "left: 518px;"
    end if
    end if
    '###Thursday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 4 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 552px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left:586px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left:6208px;"
    elseif myRS2("TruckIndex")="4" then
    response.write "left: 654px;"
    elseif myRS2("TruckIndex")="5" then
    response.write "left: 688px;"
    end if
    end if
    '###Friday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 5 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 722px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 756px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 790px;"
    elseif myRS2("TruckIndex")="4" then
    response.write "left: 824px;"
    elseif myRS2("TruckIndex")="5" then
    response.write "left: 858px;"
    end if
    end if
    '###Saturday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 6 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 892px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 926px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 960px;"
    elseif myRS2("TruckIndex")="4" then
    response.write "left: 994px;"
    elseif myRS2("TruckIndex")="5" then
    response.write "left: 1028px;"
    end if
    end if
    '###Sunday
    If WeekDay(myRS2("Sched_Date"), VBMonday) = 7 then
    If myRS2("TruckIndex")="1" then
    response.write "left: 1062px;"
    elseif myRS2("TruckIndex")="2" then
    response.write "left: 1096px;"
    elseif myRS2("TruckIndex")="3" then
    response.write "left: 1130px;"
    elseif myRS2("TruckIndex")="4" then
    response.write "left: 1164px;"
    elseif myRS2("TruckIndex")="5" then
    response.write "left: 1198px;"
    end if
    end if
    end if
    '######## AND SO ON TILL 20 TRUCKS REACHED
     
    Jake, Jan 28, 2005
    #1
    1. Advertising

  2. Jake

    McKirahan Guest

    "Jake" <> wrote in message
    news:#MZ$...
    > OK Ive got a huge amount of If Then statements that Im sure can be

    stripped
    > way down to a simple loop or two but Im not familiar enough with them to
    > know where to start.
    > Basically this is a truck scheduling application which builds a layer for
    > each schedule of each truck from Monday thru Sunday.
    > Below are the statements I have so far and I need to go up to 20 trucks. I
    > think you'll be able to tell what Im trying to do.
    > You'll notice from 3 trucks on, the layer widths are the same.
    >
    > Can someone guide me on how I can convert this to a loop to cut down the
    > amount of code?
    >
    > Thanks in advance!
    >
    > <% '############## SET DIV WIDTH DETERMINED BY TRUCK COUNT
    > If myRS("TruckTotal") = 1 then
    > response.write "132"
    > ElseIf myRS("TruckTotal") = 2 then
    > response.write "67"
    > ElseIf myRS("TruckTotal") = 3 then
    > response.write "35"
    > ElseIf myRS("TruckTotal") > 3 then
    > response.write "35"
    > End If
    > %>px;
    > <%
    > '############## Grab Day, Truck # and position div horizontally
    > #############
    > '#################################### 1 Truck ###
    > '###Monday
    > If myRS("TruckTotal") = 1 then
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 1 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 42px;"
    > end if
    > end if
    > '###Tuesday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 2 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 173px;"
    > end if
    > end if
    > '###Wednesday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 3 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 304px;"
    > end if
    > end if
    > '###Thursday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 4 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 435px;"
    > end if
    > end if
    > '###Friday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 5 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 566px;"
    > end if
    > end if
    > '###Saturday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 6 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 697px;"
    > end if
    > end if
    > '###Sunday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 7 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 828px;"
    > end if
    > end if
    > end if
    >
    > '############################ 2 Trucks ###
    > '###Monday
    > If myRS("TruckTotal") = 2 then
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 1 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 42px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 108px;"
    > end if
    > end if
    > '###Tuesday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 2 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 174px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 240px;"
    > end if
    > end if
    > '###Wednesday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 3 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 306px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 372px;"
    > end if
    > end if
    > '###Thursday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 4 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 438px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 504px;"
    > end if
    > end if
    > '###Friday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 5 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 570px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 636px;"
    > end if
    > end if
    > '###Saturday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 6 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 702px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 768px;"
    > end if
    > end if
    > '###Sunday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 7 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 834px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 900px;"
    > end if
    > end if
    > end if
    >
    > '######################### 3 Trucks ###
    > '###Monday
    > If myRS("TruckTotal") = 3 then
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 1 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 42px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 76px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 110px;"
    > end if
    > end if
    > '###Tuesday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 2 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 144px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 178px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 212px;"
    > end if
    > end if
    > '###Wednesday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 3 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 246px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 280px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 314px;"
    > end if
    > end if
    > '###Thursday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 4 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 348px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left:382px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 416px;"
    > end if
    > end if
    > '###Friday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 5 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 450px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 484px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 518px;"
    > end if
    > end if
    > '###Saturday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 6 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 552px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 586px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 620px;"
    > end if
    > end if
    > '###Sunday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 7 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 654px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 688px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 722px;"
    > end if
    > end if
    > end if
    >
    > '######################### 4 Trucks ###
    > '###Monday
    > If myRS("TruckTotal") = 4 then
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 1 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 42px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 76px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 110px;"
    > elseif myRS2("TruckIndex")="4" then
    > response.write "left: 144px;"
    >
    > end if
    > end if
    > '###Tuesday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 2 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 178px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 212px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 246px;"
    > elseif myRS2("TruckIndex")="4" then
    > response.write "left: 280px;"
    > end if
    > end if
    > '###Wednesday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 3 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 314px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 348px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 382px;"
    > elseif myRS2("TruckIndex")="4" then
    > response.write "left: 416px;"
    > end if
    > end if
    > '###Thursday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 4 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 450px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left:484px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 518px;"
    > elseif myRS2("TruckIndex")="4" then
    > response.write "left: 552px;"
    > end if
    > end if
    > '###Friday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 5 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 586px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 620px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 654px;"
    > elseif myRS2("TruckIndex")="4" then
    > response.write "left: 688px;"
    > end if
    > end if
    > '###Saturday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 6 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 722px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 756px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 790px;"
    > elseif myRS2("TruckIndex")="4" then
    > response.write "left: 824px;"
    > end if
    > end if
    > '###Sunday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 7 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 858px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 892px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 926px;"
    > elseif myRS2("TruckIndex")="4" then
    > response.write "left: 960px;"
    > end if
    > end if
    > end if
    >
    > '######################### 5 Trucks ###
    > '###Monday
    > If myRS("TruckTotal") = 5 then
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 1 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 42px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 76px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 110px;"
    > elseif myRS2("TruckIndex")="4" then
    > response.write "left: 144px;"
    > elseif myRS2("TruckIndex")="5" then
    > response.write "left: 178px;"
    >
    > end if
    > end if
    > '###Tuesday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 2 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 212px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 246px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 280px;"
    > elseif myRS2("TruckIndex")="4" then
    > response.write "left: 314px;"
    > elseif myRS2("TruckIndex")="5" then
    > response.write "left: 348px;"
    > end if
    > end if
    > '###Wednesday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 3 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 382px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 416px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 450px;"
    > elseif myRS2("TruckIndex")="4" then
    > response.write "left: 484px;"
    > elseif myRS2("TruckIndex")="5" then
    > response.write "left: 518px;"
    > end if
    > end if
    > '###Thursday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 4 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 552px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left:586px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left:6208px;"
    > elseif myRS2("TruckIndex")="4" then
    > response.write "left: 654px;"
    > elseif myRS2("TruckIndex")="5" then
    > response.write "left: 688px;"
    > end if
    > end if
    > '###Friday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 5 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 722px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 756px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 790px;"
    > elseif myRS2("TruckIndex")="4" then
    > response.write "left: 824px;"
    > elseif myRS2("TruckIndex")="5" then
    > response.write "left: 858px;"
    > end if
    > end if
    > '###Saturday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 6 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 892px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 926px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 960px;"
    > elseif myRS2("TruckIndex")="4" then
    > response.write "left: 994px;"
    > elseif myRS2("TruckIndex")="5" then
    > response.write "left: 1028px;"
    > end if
    > end if
    > '###Sunday
    > If WeekDay(myRS2("Sched_Date"), VBMonday) = 7 then
    > If myRS2("TruckIndex")="1" then
    > response.write "left: 1062px;"
    > elseif myRS2("TruckIndex")="2" then
    > response.write "left: 1096px;"
    > elseif myRS2("TruckIndex")="3" then
    > response.write "left: 1130px;"
    > elseif myRS2("TruckIndex")="4" then
    > response.write "left: 1164px;"
    > elseif myRS2("TruckIndex")="5" then
    > response.write "left: 1198px;"
    > end if
    > end if
    > end if
    > '######## AND SO ON TILL 20 TRUCKS REACHED
    >
    >


    Can you boil it down to a matrix (spreadsheet)?

    Perhaps by "TruckTotal" and "TruckIndex"; for example,

    1.1 = 42,173,304,435,566,697,828

    2.1 = 42,174,306,438,570,702,834
    2.2 = 108,240,372,504,636,768,900

    etc.

    (It would be nice if 1.1 = 2.1 etc.)


    Also, "left:6208px;" should probably be "left:620px;"
     
    McKirahan, Jan 28, 2005
    #2
    1. Advertising

  3. Jake

    Guest

    Jake wrote:
    > OK Ive got a huge amount of If Then statements that Im sure can be

    stripped
    > way down to a simple loop or two but Im not familiar enough with them

    to
    > know where to start.
    > Basically this is a truck scheduling application which builds a layer

    for
    > each schedule of each truck from Monday thru Sunday.
    > Below are the statements I have so far and I need to go up to 20

    trucks. I
    > think you'll be able to tell what Im trying to do.
    > You'll notice from 3 trucks on, the layer widths are the same.


    I would put all of this data into a database and check it against that.
    Have a range of values in the database for TruckTotal, and you'd have
    divwidth, etc.

    Then do a select based on your input parameters.
     
    , Jan 28, 2005
    #3
    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. Christopher Benson-Manica

    Need help with switch() mess

    Christopher Benson-Manica, Feb 6, 2004, in forum: C++
    Replies:
    11
    Views:
    554
    Thomas Matthews
    Feb 6, 2004
  2. Guest
    Replies:
    0
    Views:
    449
    Guest
    Feb 21, 2007
  3. Becca Girl
    Replies:
    14
    Views:
    184
    Becca Girl
    Aug 4, 2008
  4. Eric Osman
    Replies:
    2
    Views:
    426
    Eric Osman
    Apr 14, 2004
  5. Isaac Won
    Replies:
    9
    Views:
    419
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page