help with the loop pls

Discussion in 'ASP General' started by ptrlks, May 23, 2005.

  1. ptrlks

    ptrlks Guest

    Hi again,



    the problem is in this code:
    Code:
    ElseIf Right(rsBokad("aktivitet"),
    3) = "Cup" Then
    
    dStartDate = Cdate(rsBokad("startDatum"))
    
    dEndDate = Cdate(rsBokad("endDatum"))
    
    For dTempDate = dStartDate to dEndDate
    
    If cint(manad) = Month(dTempDate) AND iDag = Day(dTempDate) then
    
    Response.Write "</FONT></B></TD><TD CLASS=""tdcal""
    VALIGN=""BOTTOM"">" & rsBokad("aktivitet")
    
    Response.Write ", i " & rsBokad("lokal")
    
    End If
    
    Next
    
    ElseIf Right(rsBokad("aktivitet"), 3) = "Cam" Then
    
    dStartDate = Cdate(rsBokad("startDatum"))
    
    dEndDate = Cdate(rsBokad("endDatum"))
    
    For dTempDate = dStartDate to dEndDate
    
    If cint(manad) = Month(dTempDate) AND iDag = Day(dTempDate) then
    
    Response.Write "</FONT></B></TD><TD CLASS=""tdcal""
    VALIGN=""BOTTOM"">" & rsBokad("aktivitet")
    
    Response.Write ", i " & rsBokad("lokal")
    
    End If
    
    Next
    This is what I want to do:

    If Right(rsBokad("aktivitet"), 3) = "Cam" Then
    if dTempDate = dStartDate
    If cint(manad) = Month(dTempDate) AND iDag = Day(dTempDate) then Write
    set dTempDate = dStartDate + 1
    If cint(manad) = Month(dTempDate) AND iDag = Day(dTempDate) then Write
    set dTempDate = dStartDate + 2
    If cint(manad) = Month(dTempDate) AND iDag = Day(dTempDate) then Write
    Repeat this until dTempDate = dendDate


    Being from Sweden I apologize for my English
    Thanks in advance
    As a NOOB any help we'll be appreciated
    /Peter
     
    ptrlks, May 23, 2005
    #1
    1. Advertising

  2. ptrlks wrote:
    > Hi again,
    >
    >
    >
    > the problem is in this code:


    What are the symptoms of your problem? Don't make us attempt to run your
    code to discover your symptoms.


    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"
     
    Bob Barrows [MVP], May 23, 2005
    #2
    1. Advertising

  3. ptrlks

    ptr lks Guest

    ptr lks, May 23, 2005
    #3
  4. ptr lks wrote:
    > the symptom is: that it stops the output where
    > dTempDate = dStartDate
    >

    Ah! That helps. I have to go to work now, but I will look at this later and
    reply if nobody else has jumped in by then.

    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"
     
    Bob Barrows [MVP], May 23, 2005
    #4
  5. ptrlks

    ptrlks Guest

    "Bob Barrows [MVP]" <> wrote in message news:<#>...
    > ptr lks wrote:
    > > the symptom is: that it stops the output where
    > > dTempDate = dStartDate
    > >

    > Ah! That helps. I have to go to work now, but I will look at this later and
    > reply if nobody else has jumped in by then.
    >
    > Bob Barrows


    Hi, the pages are in swedish, but i hope the still helps you
    understand my problems:
    this page http://www45.brinkster.com/ovaasp/list.asp uses
    <%
    Session.LCID = 1053
    Set minCon = Server.CreateObject("ADODB.Connection")
    set rsBokad = Server.CreateObject("ADODB.Recordset")
    minCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
    Server.MapPath("\ovaasp\db\upptaget.mdb")
    strSQL =" SELECT * FROM upptaget ORDER by ID ASC"
    rsBokad.Open strSQL, minCon, 3, 3

    Do While Not rsBokad.EOF
    If Left(rsBokad("aktivitet"), 3) = "Trä" Then
    Response.Write "<BR>" & rsBokad("startDatum") & " " &
    rsBokad("aktivitet") & " "
    Response.Write FormatDateTime(rsBokad("startTid"), 4) & " - "
    Response.Write FormatDateTime(rsBokad("endTid"),4) & ", " &
    rsBokad("lokal") & "<BR>"
    ElseIf Left(rsBokad("aktivitet"), 2) = "Ma" Then
    Response.Write "<P>" & rsBokad("startDatum") & " " &
    rsBokad("aktivitet") & " mot "
    Response.Write rsBokad("Mot") & " i " & rsBokad("lokal") & ", kl "
    Response.Write FormatDateTime(rsBokad("startTid"), 4) & "<P>"
    ElseIf Right(rsBokad("aktivitet"), 3) = "Cup" Then
    dStartDate = Cdate(rsBokad("startDatum"))
    dEndDate = Cdate(rsBokad("endDatum"))
    For dTempDate = dStartDate to dEndDate
    Response.Write "<P>" & dTempDate & " " & rsBokad("aktivitet") & " i
    "
    Response.Write rsBokad("lokal") & "<BR>"
    Next
    ElseIf Right(rsBokad("aktivitet"), 3) = "Cam" Then
    dStartDate = Cdate(rsBokad("startDatum"))
    dEndDate = Cdate(rsBokad("endDatum"))
    For dTempDate = dStartDate to dEndDate
    Response.Write "<P>" & dTempDate & " " & rsBokad("aktivitet") & " i
    "
    Response.Write rsBokad("lokal") & "<BR>"
    Next
    Else
    Response.Write rsBokad("startDatum") & " " & rsBokad("aktivitet")
    & " i "
    Response.Write rsBokad("lokal") & "<BR>"

    End if
    rsBokad.MoveNext
    Loop

    rsBokad.Close
    Set rsBokad = Nothing
    minCon.Close
    Set minCon = Nothing
    %>
    to list contents of a database. As you see occures "Ekens Cup, Solna"
    5 times (3 - 7th jun)
    Now please
    1. visit http://www45.brinkster.com/ovaasp/skrivbordskalender115.asp
    2. check "Nästa Månad"
    3. press the button "Framåt" and you cames to jun-05
    As you see, occurs "Ekens Cup, Solna" only on 3rd of jun and not on 4,
    5, 6 and 7th why??
    the code for http://www45.brinkster.com/ovaasp/skrivbordskalender115.asp
    <%
    Response.Write "<CENTER><FONT SIZE =""4""><B>" &
    FirstVersal(MonthName(manad)) & ", " & ar & "</B></FONT></CENTER>"
    Response.Write "<CENTER><TABLE CLASS=""table"" CELLSPACING=""0""
    CELLPADDING=""1"">"
    For iDag = 1 to DatePart("d", DateSerial(ar, manad+1, 0))
    aDagar(iDag) = WeekDayName(DatePart("w",ar & "-" & manad & "-" &
    iDag))
    iWeekDay = DatePart("w",ar & "-" & manad & "-" & iDag)
    Response.Write "<TR><TD CLASS=""tdleft"" ALIGN=""CENTER""
    VALIGN=""BOTTOM""><CENTER><B><FONT SIZE=""5"">"
    Response.Write iDag
    Response.Write "</FONT></B></CENTER></TD><TD CLASS=""tdnamn""
    VALIGN=""BOTTOM"">" & FirstVersal(aDagar(iDag)) & "</TD>"
    Set minCon = Server.CreateObject("ADODB.Connection")
    set rsBokad = Server.CreateObject("ADODB.Recordset")
    minCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
    Server.MapPath("\ovaasp\db\upptaget.mdb")
    strSQL = "SELECT * FROM upptaget WHERE month(startDatum) = " & manad &
    " AND day(startDatum) = " & iDag & " ORDER by ID ASC"
    rsBokad.Open strSQL, minCon, 3, 3
    Do While Not rsBokad.EOF
    If Left(rsBokad("aktivitet"), 3) = "Trä" then
    Response.Write "</FONT></B></TD><TD CLASS=""tdcal""
    VALIGN=""BOTTOM"">" & rsBokad("aktivitet")
    Response.Write ", kl " & FormatDateTime(rsBokad("startTid"), 4) & "
    - "
    Response.Write FormatDateTime(rsBokad("endTid"), 4) & " , " &
    rsBokad("lokal")
    ElseIf Left(rsBokad("aktivitet"), 2) = "Ma" Then
    Response.Write "</FONT></B></TD><TD CLASS=""tdcal""
    VALIGN=""BOTTOM"">" & rsBokad("aktivitet")
    Response.Write " mot " & rsBokad("Mot")
    Response.Write " i " & rsBokad("lokal") & ", kl "
    Response.Write FormatDateTime(rsBokad("startTid"), 4)
    ElseIf Right(rsBokad("aktivitet"), 3) = "Cup" Then
    dStartDate = Cdate(rsBokad("startDatum"))
    dEndDate = Cdate(rsBokad("endDatum"))
    For dTempDate = dStartDate to dEndDate
    If cint(manad) = Month(dTempDate) AND iDag = Day(dTempDate) then
    Response.Write "</FONT></B></TD><TD CLASS=""tdcal""
    VALIGN=""BOTTOM"">" & rsBokad("aktivitet")
    Response.Write ", i " & rsBokad("lokal")
    End If
    Next
    ElseIf Right(rsBokad("aktivitet"), 3) = "Cam" Then
    dStartDate = Cdate(rsBokad("startDatum"))
    dEndDate = Cdate(rsBokad("endDatum"))
    For dTempDate = dStartDate to dEndDate
    If cint(manad) = Month(dTempDate) AND iDag = Day(dTempDate) then
    Response.Write "</FONT></B></TD><TD CLASS=""tdcal""
    VALIGN=""BOTTOM"">" & rsBokad("aktivitet")
    Response.Write ", i " & rsBokad("lokal")
    End If
    Next
    Else
    Response.Write "</FONT></B></TD><TD CLASS=""tdcal""
    VALIGN=""BOTTOM"">" & rsBokad("aktivitet")
    Response.Write ", i " & rsBokad("lokal")

    End if
    rsBokad.MoveNext
    Loop

    rsBokad.Close
    Set rsBokad = Nothing
    minCon.Close
    Set minCon = Nothing
    %>So my problem/Q is:
    Whu only on the 3rd and not on
    4th
    5th
    6th
    7th?
     
    ptrlks, May 24, 2005
    #5
    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. James Bond
    Replies:
    0
    Views:
    534
    James Bond
    Aug 3, 2004
  2. Rahul S.
    Replies:
    3
    Views:
    605
    Flash Gordon
    Nov 1, 2004
  3. Replies:
    1
    Views:
    281
    RedGrittyBrick
    Jan 2, 2008
  4. Emiliano
    Replies:
    2
    Views:
    323
    Rajesh.V
    Oct 16, 2003
  5. Isaac Won
    Replies:
    9
    Views:
    388
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page