calculate months between 2 dates in visual basic .net

I would like an application to fill a combobox and populate it with month, year from September of 2010.  So the combo box would look like
September, 2010
October, 2010
November, 2010
Up to the current month of when they launched the application.  How can I set that up?
Who is Participating?
John (Yiannis) ToutountzoglouConnect With a Mentor Instructor Multiengine PilotCommented:
Hi...Here is a sample...(sure there might be also another way)

 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim Stardate As DateTime = New DateTime(2010, 9, 1)
        Dim EndDate As DateTime = New DateTime(Year(Today), Month(Today), 1)
        Dim M As Integer = Math.Abs((Stardate.Year - EndDate.Year))
        Dim months As Integer = CInt(((M * 12) + Math.Abs((Stardate.Month - EndDate.Month))))

        Dim i As Integer
        For i = 0 To months 

            Me.ComboBox1.Items.Add(MonthName(Month(Stardate.AddMonths(i))) & "," & Year(Stardate.AddMonths(i)))


    End Sub

Open in new window

Hope it helps ..

chadmanvbAuthor Commented:
Perfect!  Thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.