Results 1 to 2 of 2

Thread: Combobox/ trying to populate current year plus the next 10 years.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2008
    Posts
    67

    Combobox/ trying to populate current year plus the next 10 years.

    I'm trying to use a combobox to pull the current year and then populate the next ten years. I don't want to manually put in the years in the 'item collections'. I would rather it update automatically based on the system year. How should I go about doing this?

    My first instinct is to set the combobox item to the current year based on the system date, then create a loop that increments based on on counter up to current year + 10. I'm assuming this would be done on the 'form_load' event handler???

  2. #2
    Fanatic Member
    Join Date
    Aug 2009
    Posts
    540

    Re: Combobox/ trying to populate current year plus the next 10 years.

    vb Code:
    1. ComboBox1.Text = Date.Now.Year
    2.         For i As Integer = 0 To 9
    3.             ComboBox1.Items.Add(Date.Now.Year + i)
    4.         Next

    Yah, you could put that one in the form_load event. Or if you have a sub which loads your forms data, you could put it in there.
    Where I'm from we only have one bit of advice for new comers: "If you hear banjos, turn and run".


    VS 2008 .NetFW 2.0

Posting Permissions

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



Click Here to Expand Forum to Full Width