Looping through an array. (filling table colours)

Results 1 to 3 of 3

Thread: Looping through an array. (filling table colours)

  1. #1
    Join Date
    Dec 1969

    Default Looping through an array. (filling table colours)

    I have a calendar. I have an array with 32 strings. ("yellow","white","white"........)<BR>I want to loop through my array for a month, and set the appropriate array values for the weekend days to "orange"<BR>Heres my code:<BR><BR>dim dateArray(32) &#039;32 to avoid +- 1 all the time<BR>for i = 1 to 31<BR> tempDate = "08/" & i & "/2001"<BR> if Datepart("W", tempDate) = 1 or Datepart("W", tempDate) = 7 then<BR> dateArray(i) = "orange"<BR> else<BR> dateArray(i) = "white"<BR> end if<BR>next<BR><BR>See what I do? I construct a date from the counter, and use this to figure out if the current counter number is a weekend for the month of august. If it is I set it to "orange", if not I set it to "white".<BR><BR>I then use this later to set the colours of my &#060;td&#062;s in a table.<BR><BR>Now, when I output that code, most of the weekends are fine, except for a few stray ones that 1)are not a weekend 2)are a weekend but are white.<BR><BR>There is more orange than there should be! Any clues? Correct answer wins an ASCII table.

  2. #2
    Join Date
    Dec 1969

    Default Try

    If Weekday(cdate(tempdate), vbSunday) = 1 Or Weekday(cdate(tempdate), vbSunday)=7

  3. #3
    Join Date
    Dec 1969

    Default RE: Looping through an array. (filling table colou

    How are you determining what day the value 1 belongs to, you must remember that for each new month, you would need to reprogramme the page to set the value of the first weekend day!<BR><BR>First, use the date object to create an instance of the date you are working with, the way you do this seems to be fine, use the objDate.geDay() value to determine what day of the week it is, then if objDate.getDay() = 1(Sunday), or 7(Saturday) then write (orange) else write (white).<BR><BR>Cool, hope that helps!<BR><BR>Dave

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts