CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Date

  1. #1
    Join Date
    Apr 2001
    Posts
    33

    Date

    i searching record by using date. user select the day, month and year from combo box. how i add the number of day, month and year into the combo box.

    each month have different number of days (especially in february). can i followed the system date, if so. how to do it. any code for it?

    Regards,
    Wilson Chai

  2. #2
    Join Date
    Jan 2001
    Location
    Germany
    Posts
    222

    Re: Date

    I don't know if I understood you right, but if so, you don't have to fill a combo box with dates on your own. There is an ActiveX control called MonthView. Why don't you use that to let the user pick a date?

    Teamwork Software - Stuff That Does Something

  3. #3
    Join Date
    May 2001
    Location
    India, Bangalore
    Posts
    14

    Re: Date

    Hello cyseng10,

    I think following code may help you
    To test this code add three combo boxes with names cboYear, cboMonth and cboDay

    -------------------------------------------------
    Dim intOrdDays(11) As Integer
    Dim intLeapDays(11) As Integer
    'Declaration of variables

    Private Sub cboMonth_Click()
    If ((CInt(cboYear.List(cboYear.ListIndex)) Mod 400 = 0) Or (CInt(cboYear.List(cboYear.ListIndex)) Mod 4 = 0 And (Not CInt(cboYear.List(cboYear.ListIndex)) Mod 100 = 0))) Then
    For i = 1 To intLeapDays(cboMonth.ListIndex)
    cboDay.AddItem i
    Next
    Else
    For i = 1 To intOrdDays(cboMonth.ListIndex)
    cboDay.AddItem CStr(i)
    Next
    End If
    'cboDay.Index = 10
    End Sub

    Private Sub Form_Load()

    intOrdDays(0) = 31
    intOrdDays(1) = 28
    intOrdDays(2) = 31
    intOrdDays(3) = 30
    intOrdDays(4) = 31
    intOrdDays(5) = 30
    intOrdDays(6) = 31
    intOrdDays(7) = 31
    intOrdDays(8) = 30
    intOrdDays(9) = 31
    intOrdDays(10) = 30
    intOrdDays(11) = 31

    intLeapDays(0) = 31
    intLeapDays(1) = 29
    intLeapDays(2) = 31
    intLeapDays(3) = 30
    intLeapDays(4) = 31
    intLeapDays(5) = 30
    intLeapDays(6) = 31
    intLeapDays(7) = 31
    intLeapDays(8) = 30
    intLeapDays(9) = 31
    intLeapDays(10) = 30
    intLeapDays(11) = 31

    cboYear.AddItem 2000
    cboYear.AddItem 2001
    cboYear.AddItem 2002
    cboYear.AddItem 2003
    cboYear.AddItem 2004

    cboMonth.AddItem "Jan"
    cboMonth.AddItem "Feb"
    cboMonth.AddItem "Mar"
    cboMonth.AddItem "Apr"
    cboMonth.AddItem "May"
    cboMonth.AddItem "June"
    cboMonth.AddItem "July"
    cboMonth.AddItem "Aug"
    cboMonth.AddItem "Sept"
    cboMonth.AddItem "Oct"
    cboMonth.AddItem "Nov"
    cboMonth.AddItem "Dec"
    End Sub

    'bpp



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

Featured