Click to See Complete Forum and Search --> : Date


cyseng10
June 25th, 2001, 04:25 AM
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

Captain Nuss
June 25th, 2001, 06:04 AM
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?

praveen b p
June 25th, 2001, 06:14 AM
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