Results 1 to 12 of 12

Thread: Date..........

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2000
    Location
    London, UK
    Posts
    137

    Red face

    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.

    join me in the platinum

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
        For x = 9 To Month(Now)
            Combo1.AddItem x
        Next x
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2000
    Location
    London, UK
    Posts
    137

    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,

    join me in the platinum

  4. #4
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    Use the MonthName function.


    MsgBox MonthName(Month(Now))

    [Edited by jbart on 10-12-2000 at 09:05 AM]

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 2000
    Location
    London, UK
    Posts
    137

    Talking


    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
    join me in the platinum

  7. #7
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    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]

  8. #8
    Guest

    Talking

    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...

  9. #9
    Fanatic Member faisalkm's Avatar
    Join Date
    Oct 2000
    Location
    Germany
    Posts
    752
    For i = 9 To Month(Now)
    Combo1.AddItem MonthName(i)
    Next

  10. #10
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    [code]
    for i=1 to datediff("d",cdate("01/" & month(now)),cdate("01/" & month(now)+1 ))
    list2.additem i
    next i
    [/code}
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  11. #11
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    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

  12. #12
    Guest

    Talking

    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.....

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