Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. combo boxes and additem command help me!! urgent!!

combo boxes and additem command help me!! urgent!!

Scheduled Pinned Locked Moved Visual Basic
help
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    Hi. I have several combo boxes on my form that are used to select a date. When i initialize the form i am using the additem command for each combobox, even though i am adding the same thing over and over again( days 1- 31, months 1-12, year 2001-2007. i have three seperate comboboxes to select the day , month and year. now,, i am currently using additem for each day,month,year (50 additems) for each combobox (3) for a total of 150 lines of code. can i not use additem and apply it to all three comboboxes at once(group them somehow). this doesn't work but it may give you an idea of what i am trying to accomplish with combobox1_days and combobox2_days and combobox3_days .additem 1 .additem 2 . . .additem 31 end with your help would be appreciated thanks vb addict.

    C Q 2 Replies Last reply
    0
    • A Anonymous

      Hi. I have several combo boxes on my form that are used to select a date. When i initialize the form i am using the additem command for each combobox, even though i am adding the same thing over and over again( days 1- 31, months 1-12, year 2001-2007. i have three seperate comboboxes to select the day , month and year. now,, i am currently using additem for each day,month,year (50 additems) for each combobox (3) for a total of 150 lines of code. can i not use additem and apply it to all three comboboxes at once(group them somehow). this doesn't work but it may give you an idea of what i am trying to accomplish with combobox1_days and combobox2_days and combobox3_days .additem 1 .additem 2 . . .additem 31 end with your help would be appreciated thanks vb addict.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You can in fact hard code the values into the form designer, and not do this in code at all. You can also write for loops to put numbers in, and 'group' it that way. Christian Graus - Microsoft MVP - C++

      1 Reply Last reply
      0
      • A Anonymous

        Hi. I have several combo boxes on my form that are used to select a date. When i initialize the form i am using the additem command for each combobox, even though i am adding the same thing over and over again( days 1- 31, months 1-12, year 2001-2007. i have three seperate comboboxes to select the day , month and year. now,, i am currently using additem for each day,month,year (50 additems) for each combobox (3) for a total of 150 lines of code. can i not use additem and apply it to all three comboboxes at once(group them somehow). this doesn't work but it may give you an idea of what i am trying to accomplish with combobox1_days and combobox2_days and combobox3_days .additem 1 .additem 2 . . .additem 31 end with your help would be appreciated thanks vb addict.

        Q Offline
        Q Offline
        quacks_a_lot
        wrote on last edited by
        #3

        You can index your combo boxes. To do this, add a combo box (e.g. combobox_days) to your form. Set its Index property to 0 or Copy, Paste, and press Yes when it asks you if you want to make an array. Do either one of these until you have all of the combo boxes you want. To add the items for the days: Dim intCount As Integer For intCount = 1 To 31 combobox_days(0).AddItem intCount 'This will add each day (1 through 31) to the 1st combo box combobox_days(1).AddItem intCount 'This will add each day (1 through 31) to the 2nd combo box combobox_days(2).AddItem intCount 'This will add each day (1 through 31) to the 3rd combo box Next intCount Or to comply with your message: Dim intCount As Integer 'This loop adds duplicate information to all combo boxes with the name of combobox_days For intCount = 0 To (combobox_days.Count - 1) combobox_days(intCount).AddItem 1 combobox_days(intCount).AddItem 2 combobox_days(intCount).AddItem 3 ... Next intCount Their is an ActiveX control named DTPicker that you can use by going to Projects, Components..., and selecting Windows Common Controls-2 6.0

        A 1 Reply Last reply
        0
        • Q quacks_a_lot

          You can index your combo boxes. To do this, add a combo box (e.g. combobox_days) to your form. Set its Index property to 0 or Copy, Paste, and press Yes when it asks you if you want to make an array. Do either one of these until you have all of the combo boxes you want. To add the items for the days: Dim intCount As Integer For intCount = 1 To 31 combobox_days(0).AddItem intCount 'This will add each day (1 through 31) to the 1st combo box combobox_days(1).AddItem intCount 'This will add each day (1 through 31) to the 2nd combo box combobox_days(2).AddItem intCount 'This will add each day (1 through 31) to the 3rd combo box Next intCount Or to comply with your message: Dim intCount As Integer 'This loop adds duplicate information to all combo boxes with the name of combobox_days For intCount = 0 To (combobox_days.Count - 1) combobox_days(intCount).AddItem 1 combobox_days(intCount).AddItem 2 combobox_days(intCount).AddItem 3 ... Next intCount Their is an ActiveX control named DTPicker that you can use by going to Projects, Components..., and selecting Windows Common Controls-2 6.0

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          thanks so much. i didn't know i could use a loop to fill in all the cb's values. soooo much more efficient than how i was coding it...thanks again.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups