-
Hi all,
Need some help/advice on the following issue pls.
I would like to populate a combo box with value of the months.
I want the box to be populated with the month of September and October, and for the box to add the current month in automatically. i.e if I ran the app in December I would want all months from September to December to be populated in the box.
Any ideas please.
-
Code:
For x = 9 To Month(Now)
Combo1.AddItem x
Next x
-
Month
Thanks for the above...
I know that the month pulls out a number representing the month, can it pull out the name of the month???
thanks,
-
Use the MonthName function.
MsgBox MonthName(Month(Now))
[Edited by jbart on 10-12-2000 at 09:05 AM]
-
You would have to make an array for the results:
private monthname() as string
Code:
Monthname=Array("January", "February", .... "December")
For x = 9 To Month(Now)
Combo1.AddItem Monthname(x)
Next x
-
Hi guys,
below is a some code i was working on to compare a date with a value and pull out all dates till th ecurrent month.
what would be the correct syntax for the Next m line of code, and do you think that this will work?
Sub GetDate()
FirstDate = "01/09/2000"
m = FirstDate
Do While m <= Date
n = MonthName(m) & Year(m)
AnalystCallMonitor.cbMonthFr.AddItem n & y
Next m (((would like m to equal the next month here))))))
End Sub
thanks again all
Rocks the VB Newbie
-
I am not sure, but this may help. It populates a combobox with all dates from Sept 1, 2000 to the current day's date.
Code:
Private Sub Command1_Click()
Dim startDate As Date
startDate = "08/31/2000"
While startDate < Now
startDate = DateAdd("d", 1, startDate)
Combo1.AddItem startDate
Wend
End Sub
Maybe you could use something from it for the routine you are writing.
Oops, it goes through to the next day, but you can add code to stop prior to that.
(uses the North American date format: mm/dd/yy)
[Edited by jbart on 10-12-2000 at 10:28 AM]
-
Another question, same topic...
if after we click on the december... can we have a list of all the days in that month? just like when we click filr.. it goes down... and sometime we have choice to go left...
-
For i = 9 To Month(Now)
Combo1.AddItem MonthName(i)
Next
-
[code]
for i=1 to datediff("d",cdate("01/" & month(now)),cdate("01/" & month(now)+1 ))
list2.additem i
next i
[/code}
-
Dragonyian,
The following code uses two combo boxes. Select a month from the first one and the second one shows all days for that month.
Not real pretty, but it works. Perhaps you can modify it for your use.
Code:
Option Explicit
Private Sub Form_Load()
Combo1.AddItem "January"
Combo1.AddItem "February"
Combo1.AddItem "March"
Combo1.AddItem "April"
Combo1.AddItem "May"
Combo1.AddItem "June"
Combo1.AddItem "July"
Combo1.AddItem "August"
Combo1.AddItem "September"
Combo1.AddItem "October"
Combo1.AddItem "November"
Combo1.AddItem "December"
End Sub
Private Sub Combo1_Click()
Dim selMonth As Integer
Dim startDate As Date
Dim endDate As Date
Dim yearCheck As Integer
selMonth = Combo1.ListIndex + 1
Combo2.Clear
startDate = Str(selMonth) & "/01/" & Str(Year(Now))
If selMonth <> 12 Then
yearCheck = Str(Year(Now))
Else
yearCheck = Str(Year(Now) + 1)
selMonth = "0"
End If
endDate = Str(selMonth + 1) & "/01/" & yearCheck
startDate = DateAdd("d", -1, startDate)
endDate = DateAdd("d", -1, endDate)
While startDate < endDate
startDate = DateAdd("d", 1, startDate)
Combo2.AddItem startDate
Wend
End Sub
-
Hi there: I know what you are saying, thanks for the reply... But it doesn't look VERY GOOD ... but i try to use a pop up menu, still doesn't look good..... thinking if i can make it like menu bar.....