Results 1 to 5 of 5

Thread: [RESOLVED] combobox with consecutive dates ?

  1. #1

    Thread Starter
    Addicted Member tcurrier's Avatar
    Join Date
    May 1999
    Location
    Northeastern Pa./USA
    Posts
    255

    Resolved [RESOLVED] combobox with consecutive dates ?

    Hello,

    Does anyone have a formula/function to take the current date and populate a combobox with this date and the 30 days after that ?

    Thanks for any help...
    VB6 Enterprise SP4

  2. #2
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: combobox with consecutive dates ?

    Try something like this:
    VB Code:
    1. Private Sub PopulateCombo(combo As ComboBox)
    2.  
    3.     Dim i As Long
    4.    
    5.     For i = 0 To 30
    6.         combo.AddItem DateAdd("d", i, Date)
    7.     Next i
    8.     combo.ListIndex = 0
    9.    
    10. End Sub
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  3. #3

    Thread Starter
    Addicted Member tcurrier's Avatar
    Join Date
    May 1999
    Location
    Northeastern Pa./USA
    Posts
    255

    Re: combobox with consecutive dates ?

    Thanks.... !
    VB6 Enterprise SP4

  4. #4
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: [RESOLVED] combobox with consecutive dates ?

    alternatively you could avoid calls to DateAdd and do (in the loop):
    VB Code:
    1. combo.AddItem Date + i

  5. #5
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: [RESOLVED] combobox with consecutive dates ?

    Quote Originally Posted by bushmobile
    alternatively you could avoid calls to DateAdd and do (in the loop
    Good call. Simple is better (usually) . Oh yeah, and about 60% faster too.
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

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