473,700 Members | 2,569 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help Turn IfThen mess into loop!

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("TruckTota l") = 1 then
response.write "132"
ElseIf myRS("TruckTota l") = 2 then
response.write "67"
ElseIf myRS("TruckTota l") = 3 then
response.write "35"
ElseIf myRS("TruckTota l") > 3 then
response.write "35"
End If
%>px;
<%
'############## Grab Day, Truck # and position div horizontally
#############
'############## ############### ####### 1 Truck ###
'###Monday
If myRS("TruckTota l") = 1 then
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 1 then
If myRS2("TruckInd ex")="1" then
response.write "left: 42px;"
end if
end if
'###Tuesday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 2 then
If myRS2("TruckInd ex")="1" then
response.write "left: 173px;"
end if
end if
'###Wednesday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 3 then
If myRS2("TruckInd ex")="1" then
response.write "left: 304px;"
end if
end if
'###Thursday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 4 then
If myRS2("TruckInd ex")="1" then
response.write "left: 435px;"
end if
end if
'###Friday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 5 then
If myRS2("TruckInd ex")="1" then
response.write "left: 566px;"
end if
end if
'###Saturday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 6 then
If myRS2("TruckInd ex")="1" then
response.write "left: 697px;"
end if
end if
'###Sunday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 7 then
If myRS2("TruckInd ex")="1" then
response.write "left: 828px;"
end if
end if
end if

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

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

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

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

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

end if
end if
'###Tuesday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 2 then
If myRS2("TruckInd ex")="1" then
response.write "left: 212px;"
elseif myRS2("TruckInd ex")="2" then
response.write "left: 246px;"
elseif myRS2("TruckInd ex")="3" then
response.write "left: 280px;"
elseif myRS2("TruckInd ex")="4" then
response.write "left: 314px;"
elseif myRS2("TruckInd ex")="5" then
response.write "left: 348px;"
end if
end if
'###Wednesday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 3 then
If myRS2("TruckInd ex")="1" then
response.write "left: 382px;"
elseif myRS2("TruckInd ex")="2" then
response.write "left: 416px;"
elseif myRS2("TruckInd ex")="3" then
response.write "left: 450px;"
elseif myRS2("TruckInd ex")="4" then
response.write "left: 484px;"
elseif myRS2("TruckInd ex")="5" then
response.write "left: 518px;"
end if
end if
'###Thursday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 4 then
If myRS2("TruckInd ex")="1" then
response.write "left: 552px;"
elseif myRS2("TruckInd ex")="2" then
response.write "left:586px ;"
elseif myRS2("TruckInd ex")="3" then
response.write "left:6208p x;"
elseif myRS2("TruckInd ex")="4" then
response.write "left: 654px;"
elseif myRS2("TruckInd ex")="5" then
response.write "left: 688px;"
end if
end if
'###Friday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 5 then
If myRS2("TruckInd ex")="1" then
response.write "left: 722px;"
elseif myRS2("TruckInd ex")="2" then
response.write "left: 756px;"
elseif myRS2("TruckInd ex")="3" then
response.write "left: 790px;"
elseif myRS2("TruckInd ex")="4" then
response.write "left: 824px;"
elseif myRS2("TruckInd ex")="5" then
response.write "left: 858px;"
end if
end if
'###Saturday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 6 then
If myRS2("TruckInd ex")="1" then
response.write "left: 892px;"
elseif myRS2("TruckInd ex")="2" then
response.write "left: 926px;"
elseif myRS2("TruckInd ex")="3" then
response.write "left: 960px;"
elseif myRS2("TruckInd ex")="4" then
response.write "left: 994px;"
elseif myRS2("TruckInd ex")="5" then
response.write "left: 1028px;"
end if
end if
'###Sunday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 7 then
If myRS2("TruckInd ex")="1" then
response.write "left: 1062px;"
elseif myRS2("TruckInd ex")="2" then
response.write "left: 1096px;"
elseif myRS2("TruckInd ex")="3" then
response.write "left: 1130px;"
elseif myRS2("TruckInd ex")="4" then
response.write "left: 1164px;"
elseif myRS2("TruckInd ex")="5" then
response.write "left: 1198px;"
end if
end if
end if
'######## AND SO ON TILL 20 TRUCKS REACHED
Jul 22 '05 #1
3 1287
Look at the Case statement

--
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Jake" <sp******@allte l.net> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
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("TruckTota l") = 1 then
response.write "132"
ElseIf myRS("TruckTota l") = 2 then
response.write "67"
ElseIf myRS("TruckTota l") = 3 then
response.write "35"
ElseIf myRS("TruckTota l") > 3 then
response.write "35"
End If
%>px;
<%
'############## Grab Day, Truck # and position div horizontally
#############
'############## ############### ####### 1 Truck ###
'###Monday
If myRS("TruckTota l") = 1 then
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 1 then
If myRS2("TruckInd ex")="1" then
response.write "left: 42px;"
end if
end if
'###Tuesday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 2 then
If myRS2("TruckInd ex")="1" then
response.write "left: 173px;"
end if
end if
'###Wednesday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 3 then
If myRS2("TruckInd ex")="1" then
response.write "left: 304px;"
end if
end if
'###Thursday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 4 then
If myRS2("TruckInd ex")="1" then
response.write "left: 435px;"
end if
end if
'###Friday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 5 then
If myRS2("TruckInd ex")="1" then
response.write "left: 566px;"
end if
end if
'###Saturday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 6 then
If myRS2("TruckInd ex")="1" then
response.write "left: 697px;"
end if
end if
'###Sunday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 7 then
If myRS2("TruckInd ex")="1" then
response.write "left: 828px;"
end if
end if
end if

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

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

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

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

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

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

Jul 22 '05 #2
"Jake" <sp******@allte l.net> wrote in message
news:#M******** ******@TK2MSFTN GP15.phx.gbl...
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("TruckTota l") = 1 then
response.write "132"
ElseIf myRS("TruckTota l") = 2 then
response.write "67"
ElseIf myRS("TruckTota l") = 3 then
response.write "35"
ElseIf myRS("TruckTota l") > 3 then
response.write "35"
End If
%>px;
<%
'############## Grab Day, Truck # and position div horizontally
#############
'############## ############### ####### 1 Truck ###
'###Monday
If myRS("TruckTota l") = 1 then
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 1 then
If myRS2("TruckInd ex")="1" then
response.write "left: 42px;"
end if
end if
'###Tuesday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 2 then
If myRS2("TruckInd ex")="1" then
response.write "left: 173px;"
end if
end if
'###Wednesday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 3 then
If myRS2("TruckInd ex")="1" then
response.write "left: 304px;"
end if
end if
'###Thursday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 4 then
If myRS2("TruckInd ex")="1" then
response.write "left: 435px;"
end if
end if
'###Friday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 5 then
If myRS2("TruckInd ex")="1" then
response.write "left: 566px;"
end if
end if
'###Saturday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 6 then
If myRS2("TruckInd ex")="1" then
response.write "left: 697px;"
end if
end if
'###Sunday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 7 then
If myRS2("TruckInd ex")="1" then
response.write "left: 828px;"
end if
end if
end if

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

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

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

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

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

end if
end if
'###Tuesday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 2 then
If myRS2("TruckInd ex")="1" then
response.write "left: 212px;"
elseif myRS2("TruckInd ex")="2" then
response.write "left: 246px;"
elseif myRS2("TruckInd ex")="3" then
response.write "left: 280px;"
elseif myRS2("TruckInd ex")="4" then
response.write "left: 314px;"
elseif myRS2("TruckInd ex")="5" then
response.write "left: 348px;"
end if
end if
'###Wednesday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 3 then
If myRS2("TruckInd ex")="1" then
response.write "left: 382px;"
elseif myRS2("TruckInd ex")="2" then
response.write "left: 416px;"
elseif myRS2("TruckInd ex")="3" then
response.write "left: 450px;"
elseif myRS2("TruckInd ex")="4" then
response.write "left: 484px;"
elseif myRS2("TruckInd ex")="5" then
response.write "left: 518px;"
end if
end if
'###Thursday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 4 then
If myRS2("TruckInd ex")="1" then
response.write "left: 552px;"
elseif myRS2("TruckInd ex")="2" then
response.write "left:586px ;"
elseif myRS2("TruckInd ex")="3" then
response.write "left:6208p x;"
elseif myRS2("TruckInd ex")="4" then
response.write "left: 654px;"
elseif myRS2("TruckInd ex")="5" then
response.write "left: 688px;"
end if
end if
'###Friday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 5 then
If myRS2("TruckInd ex")="1" then
response.write "left: 722px;"
elseif myRS2("TruckInd ex")="2" then
response.write "left: 756px;"
elseif myRS2("TruckInd ex")="3" then
response.write "left: 790px;"
elseif myRS2("TruckInd ex")="4" then
response.write "left: 824px;"
elseif myRS2("TruckInd ex")="5" then
response.write "left: 858px;"
end if
end if
'###Saturday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 6 then
If myRS2("TruckInd ex")="1" then
response.write "left: 892px;"
elseif myRS2("TruckInd ex")="2" then
response.write "left: 926px;"
elseif myRS2("TruckInd ex")="3" then
response.write "left: 960px;"
elseif myRS2("TruckInd ex")="4" then
response.write "left: 994px;"
elseif myRS2("TruckInd ex")="5" then
response.write "left: 1028px;"
end if
end if
'###Sunday
If WeekDay(myRS2(" Sched_Date"), VBMonday) = 7 then
If myRS2("TruckInd ex")="1" then
response.write "left: 1062px;"
elseif myRS2("TruckInd ex")="2" then
response.write "left: 1096px;"
elseif myRS2("TruckInd ex")="3" then
response.write "left: 1130px;"
elseif myRS2("TruckInd ex")="4" then
response.write "left: 1164px;"
elseif myRS2("TruckInd ex")="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:6208p x;" should probably be "left:620px ;"
Jul 22 '05 #3

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.

Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1840
by: Khen Chzakuv | last post by:
Fred wants an e-commerce website. He commissions Jo, a freelancer who is a good web designer and knows a little about programming (from an extremely sub-standard university), to create the website for him. Jo sets to work creating lots of pretty HTML pages with calls to as-yet-unwritten PHP scripts mixed in with the HTML and Javascript. To explain what these scripts are supposed to do, Jo inserts drastically brief comments into the design...
15
2743
by: Buck Rogers | last post by:
Hi guys! Task 1: Write a program which presents a menu with 5 options. The 5th option quits the program. Each option should execute a system command using system(). Below is my humble offering. =================================================== #include <stdio.h> #include <stdlib.h>
23
3271
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application to create certain textboxes, labels, and combo boxes? Any ideas would be appreciated. Thanks
17
1972
by: VM | last post by:
In my Windows app, I'm running a batch process that's composed of a FOR loop that'll run 15,000 times (datatable row count), copy cthe data of each row -3 fields- to a struct, and send the strct to an external method (using DLLImport). The problem is that the processing speed is very inconsistent- it may run very FAST during certain points but then it runs VERY slow at other moments (especially when it's getting to the end of the table:...
4
1234
by: carl.manaster | last post by:
Hi, Group, I prefer indenting braces with their block, thus: public int Foo() .....{ .....Bar(); .....}
8
1458
by: bmlclemson08 | last post by:
Hey if anyone could I need to find out how to write a program that will read in any number of integers, including none, and determine which is the largest integer. The part i can't figure out is getting the program to read any number of integers. Any ideas at all would be wonderful. here's the code for what i have so far. #include <stdio.h> int main () {
8
3794
by: sabirah | last post by:
My code does not seem to be working properly... The game is b/w a human and the computer. The computer always goes first. The computer chooses the first corner in the first turn. in the comp's 2nd turn, it chooses the opposite corner if possible, if that corner is not availabe, the computer chooses randomly. In the computers next turns...it does the following: 1. checks for a winning position else 2. blocks human from a winning...
9
1907
by: TF | last post by:
Hello all, I made a ASP.NET 2.0 site that shows possible "recipes" for paint colors stored in an access dbase. Basically, 1000 colors are stored with specific RGB values in separate columns. A user sees all the colors listed on the page with hyperlinks that open the "mixes" page. The mixes page goes through each record, compares it with all other records in a ratio up to "maxratio". If it finds a ratio that matches the redvalue of...
1
1832
by: trav4 | last post by:
I have an assignment for school and I am new to programming. For the assignment I need to make a survey with at least 4 choices that uses 2 arrays. It must be done in a console application. How do I make it loop and count/store the responses until the user enters "N" at strAnswer=Console.readline? Where/what loop would I use? Module Module1 Sub Main() Dim strAnswer As String Console.WriteLine("Do you want to...
0
8731
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9218
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9081
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8929
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4408
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4660
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2031
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.