combo boxes and additem command help me!! urgent!!
-
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.
-
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.
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++
-
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.
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
-
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