Hello
I've have got it working more or less, but there is still a small glitch. The first color in the sequence displays briefly, then the backcolor goes white again, then the colors display in sequence for 5 seconds each as they are supposed to do. I will paste the entire code below, and I'm hoping that someone will paste it into notepad and give it an aspx extension and run it to experience the glitch noted above. Hopefully someone can then show me how to go straight into the color sequence without the initial glitch.
Thanks for helping thus far. Your insights are appreciated:
Here's the code:
*********************
<%@ Page Language= "VB" debug="true" SmartNavigation="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDB" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Drawing" %>
<Script Language="VB" runat="Server">
'
'**************************************************************
Sub Page_Load(s as object, e as eventArgs)
Dim i as integer
If Not Page.IsPostback Then
For i = 1 to 12
ddlMonths.Items.Add( i )
Next i
For i = 1 to 31
ddlDays.Items.Add( i )
Next i
For i = 1940 to 2010
ddlYears.Items.Add( i )
Next i
For i = 1 to 12
ddlHour.Items.Add( i )
Next i
For i = 0 to 59
ddlMin.Items.Add( i )
Next i
ddlAMPM.Items.Add("AM")
ddlAMPM.Items.Add("PM")
End If
If Page.IsPostBack Then
Get1stColor()
End If
End Sub
'**************************************************************
Sub Get1stColor()
Dim iWeekday As Integer
Dim s1st As String
Dim sRemain As String
Dim sDate as string
sDate = ddlmonths.SelectedItem.value + "/" + ddldays.SelectedItem.value + "/" + ddlyears.SelectedItem.value
iWeekday = Weekday(sDate)
Select Case iWeekday
Case 1
s1st = "G"
sRemain = "FEDCBA"
Case 2
s1st = "F"
sRemain = "EDCBAG"
Case 3
s1st = "E"
sRemain = "DCBAGF"
Case 4
s1st = "D"
sRemain = "CBAGFE"
Case 5
s1st = "C"
sRemain = "BAGFED"
Case 6
s1st = "B"
sRemain = "AGFEDC"
Case 7
s1st = "A"
sRemain = "GFEDCB"
End Select
Call Get2ndColor(s1st, sRemain)
End Sub
'**************************************************************
Sub Get2ndColor(s1st As String, sRemain As String)
Dim iAMPM As Integer
Dim sAMPM as string
Dim iHr As Integer
Dim iMin As Integer
Dim iMinTotal As Integer
Dim s2nd As String
Dim sMyColors As String
Dim iMinRemain As Integer
If ddlHour.SelectedItem.value = 12 and ddlAMPM.SelectedItem.value = "AM" then
iHr = 0
Else
iHr = ddlHour.SelectedItem.value
End If
iMin = ddlMin.SelectedItem.value
sAMPM = ddlAMPM.SelectedItem.value
If sAMPM = "AM" Then iAMPM = 0
If sAMPM = "PM" Then iAMPM = 720
iMinTotal = iAMPM + (iHr * 60) + iMin
Select Case iMinTotal
Case Is < 240
s2nd = Mid(sRemain, 1, 1)
sRemain = Mid(sRemain, 2, 5)
Case 240 To 479
s2nd = Mid(sRemain, 2, 1)
sRemain = Mid(sRemain, 3, 4) & Mid(sRemain, 1, 1)
Case 480 To 719
s2nd = Mid(sRemain, 3, 1)
sRemain = Mid(sRemain, 4, 3) & Mid(sRemain, 1, 2)
Case 720 To 959
s2nd = Mid(sRemain, 4, 1)
sRemain = Mid(sRemain, 5, 2) & Mid(sRemain, 1, 3)
Case 960 To 1199
s2nd = Mid(sRemain, 5, 1)
sRemain = Mid(sRemain, 6, 1) & Mid(sRemain, 1, 4)
Case 1200 To 1439
s2nd = Mid(sRemain, 6, 1)
sRemain = Mid(sRemain, 1, 5)
End Select
sMyColors = s1st & s2nd
iMinRemain = iMinTotal Mod 240
Call Get3rdColor(iMinRemain, sMyColors, sRemain)
End Sub
'**************************************************************
Sub Get3rdColor(iMinRemain As Integer, sMyColors As String, sRemain As String)
Dim s3rd As String
Select Case iMinRemain
Case Is < 48
s3rd = Mid(sRemain, 1, 1)
sRemain = Mid(sRemain, 2, 4)
Case 48 To 95
s3rd = Mid(sRemain, 2, 1)
sRemain = Mid(sRemain, 3, 3) & Mid(sRemain, 1, 1)
Case 96 To 143
s3rd = Mid(sRemain, 3, 1)
sRemain = Mid(sRemain, 4, 2) & Mid(sRemain, 1, 2)
Case 144 To 191
s3rd = Mid(sRemain, 4, 1)
sRemain = Mid(sRemain, 5, 1) & Mid(sRemain, 1, 3)
Case 192 To 239
s3rd = Mid(sRemain, 5, 1)
sRemain = Mid(sRemain, 1, 4)
End Select
sMyColors = sMyColors & s3rd
iMinRemain = iMinRemain Mod 48
Call Get4thColor(iMinRemain, sMyColors, sRemain)
End Sub
'**************************************************************
Sub Get4thColor(iMinRemain As Integer, sMyColors As String, sRemain As String)
Dim s4th As String
Select Case iMinRemain
Case Is < 12
s4th = Mid(sRemain, 1, 1)
sRemain = Mid(sRemain, 2, 3)
Case 12 To 23
s4th = Mid(sRemain, 2, 1)
sRemain = Mid(sRemain, 3, 2) & Mid(sRemain, 1, 1)
Case 24 To 35
s4th = Mid(sRemain, 3, 1)
sRemain = Mid(sRemain, 4, 1) & Mid(sRemain, 1, 2)
Case 36 To 47
s4th = Mid(sRemain, 4, 1)
sRemain = Mid(sRemain, 1, 3)
End Select
sMyColors = sMyColors & s4th
iMinRemain = iMinRemain Mod 12
Call Get5thColor(iMinRemain, sMyColors, sRemain)
End Sub
'**************************************************************
Sub Get5thColor(iMinRemain As Integer, sMyColors As String, sRemain As String)
Dim s5th As String
Select Case iMinRemain
Case Is < 4
s5th = Mid(sRemain, 1, 1)
sRemain = Mid(sRemain, 2, 2)
Case 4 To 7
s5th = Mid(sRemain, 2, 1)
sRemain = Mid(sRemain, 3, 1) & Mid(sRemain, 1, 1)
Case 8 To 11
s5th = Mid(sRemain, 3, 1)
sRemain = Mid(sRemain, 1, 2)
End Select
sMyColors = sMyColors & s5th
iMinRemain = iMinRemain Mod 4
Call Get6and7thColors(iMinRemain, sMyColors, sRemain)
End Sub
'**************************************************************
Sub Get6and7thColors(iMinRemain As Integer, sMyColors As String, sRemain As String)
Dim s6th As String
Select Case iMinRemain
Case Is < 2
s6th = Mid(sRemain, 1, 1)
sRemain = Mid(sRemain, 2, 1)
Case 2 To 3
s6th = Mid(sRemain, 2, 1)
sRemain = Mid(sRemain, 1, 1)
End Select
sMyColors = sMyColors & s6th & sRemain
txtSequence.visible = "true"
txtSequence.text = sMyColors
Call ShowColors(sMyColors)
End Sub
'**************************************************************
Sub ShowColors(sMyColors as string)
Dim sColor(6) as string
Dim i as integer
Dim Color as string
Dim txtColors as textBox
'Dim sLetter as string
sColor(0) = Left(sMyColors,1)
sColor(1) = Mid(sMyColors,2,1)
sColor(2) = Mid(sMyColors,3,1)
sColor(3) = Mid(sMyColors,4,1)
sColor(4) = Mid(sMyColors,5,1)
sColor(5) = Mid(sMyColors,6,1)
sColor(6) = Mid(sMyColors,7,1)
For i = 0 to 6
Select case sColor(i)
Case "G"
Color = "purple"
Case "F"
Color = "blueviolet"
Case "E"
Color = "blue"
Case "D"
Color = "green"
Case "C"
Color = "yellow"
Case "B"
Color = "orange"
Case "A"
Color = "red"
End Select
txtColors = CType(FindControl("txt" & i+1), TextBox)
txtColors.backcolor = ColorTranslator.FromHtml(Color)
Next i
btnJavaScript.text = "Display Colors"
Call RunJavaScript( )
End Sub
'**************************************************************
Sub RunJavaScript()
btnJavaScript.Attributes.Add("onClick", "return enterColorString( );")
End Sub
'**************************************************************
</script>
<html>
<head>
<script language = "JavaScript">
var theTimeout;
var colorString;
var strColor;
var sFont;
var intNum = 0;
var intSecs;
var intTotalSecs;
var index;
function enterColorString( )
{
colorString = document.getElementById("txtSequence").value ;
//intSecs = prompt("How many seconds between color changes?", "5");
intSecs = 5
intTotalSecs = parseInt(intSecs) * 1000
upDate( );
}
function upDate()
{
var theNumber = intNum;
var theNumberLoop = (theNumber % 7) + 1;
theNumber = parseInt(theNumber) + 1;
intNum = theNumber;
theTimeout = setTimeout("upDate();", intTotalSecs)
getColors();
switch (theNumberLoop)
{
case 1:
document.bgColor = strColor[0];
lbl1.innerText="I'm having the time of my life!";
break;
case 2:
document.bgColor = strColor[1];
lbl1.innerText="No worries on my mind!";
break;
case 3:
document.bgColor = strColor[2];
lbl1.innerText="Everything is just fine!";
break;
case 4:
document.bgColor = strColor[3];
lbl1.innerText="Today is even better than yesterday!";
break;
case 5:
document.bgColor = strColor[4];
lbl1.innerText="Everything is going my way!";
break;
case 6:
document.bgColor = strColor[5];
lbl1.innerText="I'm living in the big time!";
break;
case 7:
document.bgColor = strColor[6];
lbl1.innerText="Generating my daily income is surprisingly fun & easy!";
break;
}
}
function getColors( )
{
strColor = new Array(colorString.substring(0,1), colorString.substring(1,2), colorString.substring(2,3), colorString.substring(3,4),
colorString.substring(4,5), colorString.substring(5,6), colorString.substring(6,7))
for (index = 0; index <7; index++)
{
switch (strColor[index])
{
case "G":
strColor[index] = "purple";
break;
case "F":
strColor[index] = "blueviolet";
break;
case "E":
strColor[index] = "blue";
break;
case "D":
strColor[index] = "green";
break;
case "C":
strColor[index] = "yellow";
break;
case "B":
strColor[index] = "orange";
break;
case "A":
strColor[index] = "red";
break;
}
}
}
</script>
<style type="text/css">
.mytable
{ font-family:sans-serif;
font-size:8pt;
color:black; }
</style>
</head>
<body>
<form runat='server'>
<table class = 'myTable'>
<tr>
<td width='50'><ASP:label ID='lblmonths' text='Month' font-bold='true' runat='server' /></td>
<td width='50'><ASP:label ID='lbldays' text='Day' font-bold='true' runat='server' /></td>
<td width='50'><ASP:label ID='lblyears' text='Year' font-bold='true' runat='server' /></td>
<td width='50'><ASP:label ID='lblHour' text='Hour' font-bold='true' runat='server' /></td>
<td width='50'><ASP:label ID='lblMin' text='Min' font-bold='true' runat='server' /></td>
<td width='50'><ASP:label ID='lblAMPM' text='AM/PM' font-bold='true' runat='server' /></td>
</tr>
<tr>
<td><ASP

ropDownList ID='ddlmonths' runat='server' /></td>
<td><ASP

ropDownList ID='ddldays' runat='server' /></td>
<td><ASP

ropDownList ID='ddlyears' runat='server' /></td>
<td><ASP

ropDownList ID='ddlHour' runat='server' /></td>
<td><ASP

ropDownList ID='ddlMin' runat='server' /></td>
<td><ASP

ropDownList ID='ddlAMPM' runat='server' /></td>
<td>
<asp:TextBox Id='txt1' width='20' height='20' runat='server' />
</td>
<td>
<asp:TextBox Id='txt2' width='20' height='20' runat='server' />
</td>
<td>
<asp:TextBox Id='txt3' width='20' height='20' runat='server' />
</td>
<td>
<asp:TextBox Id='txt4' width='20' height='20' runat='server' />
</td>
<td>
<asp:TextBox Id='txt5' width='20' height='20' runat='server' />
</td>
<td>
<asp:TextBox Id='txt6' width='20' height='20' runat='server' />
</td>
<td>
<asp:TextBox Id='txt7' width='20' height='20' runat='server' />
</td>
<td>
<asp:TextBox id='txtSequence' visible = 'false' font-size='12pt' font-bold='true' width = '90' runat='Server'/>
</td>
<td>
<ASP:button width='100' Id='btnJavaScript' on_click='Get1stColor' Text='Get Sequence' font-bold='true' runat='server' />
</td>
</tr>
</table><br>
<asp:label ID = 'lblAffirm' runat='Server'/>
</form>
</body>
<body language=JavaScript onload="return window_onload( )">
<form name = "theForm">
<input type = 'button' value = 'Stop' onClick = 'clearTimeout(theTimeout);'><br><br><br><br>
<table align = 'center' valign='middle'>
<tr>
<td><font color = "white" size='7'><label ID="lbl1"></label></font></td>
</tr>
</table>
</form>
</body>
</html>