Help filling comboBox with Week End Dates

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Jake (Jake_at_discussions.microsoft.com)
Date: 07/19/04


Date: Mon, 19 Jul 2004 12:57:04 -0700

Hello,

I am a long time VB programmer moving to C#. I am trying to fill a comboBox in C# with Week End Dates. The code I would use in VB would be the following.

        Dim ThisDay As DateTime = Today
        Dim EndOfWeek As DateTime = Today

        If Not ThisDay.DayOfWeek = DayOfWeek.Sunday Then
            Do Until EndOfWeek.DayOfWeek = DayOfWeek.Sunday
                EndOfWeek = EndOfWeek.Add(TimeSpan.FromDays(1))
            Loop
        Else
            EndOfWeek = ThisDay
        End If

        Dim WeekCount As Integer

        For WeekCount = -5 To 5
            Me.ComboBox1.Items.Add(DateAdd(DateInterval.WeekOfYear, WeekCount, EndOfWeek).ToShortDateString)
        Next

unable to use DateAdd and DateInterval in C# I have been stuck on this solution for some time. Any help from a long time C# guru would be great.

Thanks in advance.
Jake



Relevant Pages

  • Please Help on Object Library Invalid or contains....
    ... Thank you very much for opening my message. ... problem on my project and I am stuck on this issue - "Object library invalid ... or contains references to object definitions that could not be found". ... cells in my worksheet, when I add one new combobox and then I compile in VBE, ...
    (microsoft.public.excel.programming)
  • RE: Please Help
    ... Thank you very much for opening my message. ... problem on my project and I am stuck on this issue - "Object library invalid ... or contains references to object definitions that could not be found". ... cells in my worksheet, when I add one new combobox and then I compile in VBE, ...
    (microsoft.public.excel.programming)
  • RE: Range method error
    ... your code or the part that the error is getting stuck on? ... "EXCELKO" wrote: ... I using commandbuttons to move between sheets and ... The error reports from the code within the ComboBox - Is this ...
    (microsoft.public.excel.programming)
  • Re: Get reference to Combobox in Datagridview
    ... I'm stuck on the following seemingly easy issue? ... When I know the row nr and column nr of a cell in a datagridview with ... a combobox in it how do I get a reference to that combobox? ...
    (microsoft.public.dotnet.general)
  • Re: Combo Box interacting to Table
    ... I still got stuck with this VB script that you gave, ... enter a new cust name on the combobox. ...
    (microsoft.public.access.forms)