1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Newbie ASP.net question

Discussion in 'C#' started by QuEST, Mar 10, 2008.

  1. #1
    Hi!

    I am a total newbie..

    i have a question, consider if i have two dates example...

    DateTime dt1 = DateTime.Now;
    DateTime dt2 = dt1.AddDays(45);

    Now i want to list all the dates in between these and display in a listbox or a lablel..

    how do i create a loop?

    can someone suggest!

    Thanks in advance

    Regards
     
    QuEST, Mar 10, 2008 IP
  2. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #2
    At the moment with your example there would be little point in doing the second line but assuming dt2 is user contribution or such then

    
            Dim dt1 As DateTime = Now
            Dim dt2 As DateTime = Now.AddDays(45)
            
            For i As Integer = 0 To DateDiff(DateInterval.Day, dt1, dt2)
                Label1.Text &= dt1.AddDays(i).ToString("M/d/yy") & "<br />"
            Next
    
    Code (ASP.Net):
     
    AstarothSolutions, Mar 10, 2008 IP