Listing Days And Months - I Found A Solution 
Author Message
 Listing Days And Months - I Found A Solution

Thanks for everyone posting their theories on how to get and display the
number of days based on which month is selected, but I actually found a
solution to my problem.

Create a project and place two combos on the form then place the following
code into the project:

    Private Sub Combo1_Click ()
        Dim i As Integer
        For i = 1 to DateDiff("d", DateValue(Combo1.Text & "/1/" & _
                Format(Now(), "yyyy")), DateAdd("m", 1, Combo1.Text & _
                "/1/" & Format(Now(), "yyyy")))
            Combo2.Additem i
        Next i
    End Sub

    Private Sub Form1_Load ()
        Dim i As Integer
        For i = 0 to 11
            Combo1.Additem Format(DateAdd("m", i, DateValue("1/1/" & _
                Format(Now(), "yyyy"))), "mmmm")
        Next i
    End Sub

This code will even account for Leap Years. Just try it, it does work.
Change your system date to the year 2000, 2004 and so on and select February
from the first combo. Then display the value in the second combo.

Darren O'Leary

Sat, 13 Apr 2002 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Listing Months, Days and Years in seperate drop combos

2. Listing Days And Months

3. Listing Months, Days and Years in seperate drop combos

4. Listing Months, Days and Years in seperate drop combos

5. Find last day in a month

6. Function to find the last day or Date of a given month

7. Converting Days to Years, Months and Days

8. Return Month/Day from Day Number

9. Happy Days - I found the solution

10. last day of month, or first day of month ?

11. Find day of the week for first day of a month?

12. Calculate no of days in a month within a specified date range


Powered by phpBB® Forum Software