Combo boxes are so-named because they "combine" the features found in both text boxes and list boxes. Combo boxes are also commonly referred to as "drop-down boxes" or "drop-down lists". There are three combo box styles:
At design-time, you set the style of the combo box with its Style property.
Of the three combo box styles, the one most similar to a ListBox is "2 - Drop-Down List". In fact, everything discussed in the last several pages regarding ListBoxes applies to drop-down style combo boxes EXCEPT the following:
The combo box displays the selected item in the text box portion of the combo box. The ListBox portion of the combo box remains hidden until the combo box receives focus and the user clicks the down arrow on the text box.
You can change the width of a drop-down combo box, but not its height.
Like a ListBox, and unlike the other combo box styles, the user can only select a value that is in the list they cannot type in a new value. However, if the user does press a keyboard key, the closest item in the list alphabetically will be selected (i.e., if the user types the letter "B", and the word "Banana" is in the list, then "Banana" will be selected).
Multiple selections cannot be made. Only one item may be selected from the list.
Unlike a ListBox, VB does not automatically pre-select the first value from a combo box. Therefore, the initial value of the ListIndex property is 1. If you do not pre-select a value in code (say in the Form_Load procedure), then be sure to check the ListIndex property for a value of 1 when you check to see which item the user selected.
The "0 Drop Down Combo" style of combo box operates the same way as the Drop Down List, except that the user may type a new value in the text box portion of the combo box. Please note that if the user types a non-list value, this value is NOT automatically added to the list, and the value of ListIndex would be 1. You should check the Text property to access the user's selection or entry.
The "1 Simple Combo" style of combo box operates in a manner similar to the Drop Down Combo in that the user can either select an item from the list or type a new entry. The difference is that the list does not drop down like a ListBox, you determine the height of the list portion at design-time. This is the only combo-box style that allows you to adjust the height of the list portion.
Combo Box Demo Program
A sample program to demonstrate the three combo box styles will now be presented. The form at design-time is shown below:

Frame1 has the Caption 'Style "2 Dropdown List"' and contains a combo box named cboFood with its Style property set to 2 Dropdown List. It also contains three command buttons, named cmdLoadFoodCombo, cmdSelect, and cmdDetermine. It also contains a checkbox named chkAuto.
Frame2 has the Caption 'Style "0 Dropdown Combo"' and contains a combo box named cboStateAbbrev with its Style property set to 0 Dropdown Combo. It also contains two command buttons, named cmdLoadStateAbbrevCombo and cmdAddNewAbbrev.
Frame3 has the Caption 'Style "1 Simple Combo"' and contains a combo box named cboStateName with its Style property set to 1 Simple Combo. It also contains two command buttons, named cmdLoadStateNameCombo and cmdAddNewName.
We will first look at the code dealing with the Dropdown List style of the combo box.
The cmdLoadFoodCombo_Click Event
In this event, we first clear the cboFood combo box, then manually add three food items along with their calorie count in the corresponding ItemData property. (See the earlier discussion "Getting Data into a Listbox" for more detail.) We then inform the user that the combo box has been loaded.
Private Sub cmdLoadFoodCombo_Click()
cboFood.Clear
cboFood.AddItem "Orange"
cboFood.ItemData(cboFood.NewIndex) = 60
cboFood.AddItem "Apple"
cboFood.ItemData(cboFood.NewIndex) = 80
cboFood.AddItem "Banana"
cboFood.ItemData(cboFood.NewIndex) = 105
MsgBox "Food combo box has been loaded.", _
vbInformation, _
"Combo Box Demo"
End Sub
Note: When you run the sample application and click this button, you will not initially see these items, because we are not pre-selecting any item:

You have to click the down arrow on the combo box to see the items:

If you wanted to pre-select an item in the combo box, you would set the ListIndex property to the index of the desired entry. For example, the statement cboFood.ListIndex = 0 would pre-select the first item in the box.
The cmdSelect_Click Event
The purpose of the code behind the cmdSelect button is to show how to select a specific entry from a combo box in code. Given an item to match against, you loop through the entries in the combo box until you either find a matching entry or you go through the entire list without finding the entry. If you find the desired entry, you set the ListIndex property to that of the matching entry and exit the loop early. In this example, an InputBox prompts the user to enter a food. We then loop through the entries of the combo box, comparing the current List entry to the food item entered in the InputBox. If and when the item is found, the ListIndex is set accordingly.
Private Sub cmdSelect_Click()
Dim strFood As String
Dim intX As Integer
Dim blnFound As Boolean
strFood = InputBox("Please enter the food to select (apple, orange, or banana).", _
"Combo Box Demo - Select with Code")
If strFood = "" Then Exit Sub
blnFound = False
For intX = 0 To cboFood.ListCount - 1
If UCase$(cboFood.List(intX)) = UCase$(strFood) Then
cboFood.ListIndex = intX
blnFound = True
Exit For
End If
Next
If Not blnFound Then
MsgBox "Item was not found in the list.", _
vbExclamation, _
"Combo Box Demo"
End If
End Sub
Below are screen shots of a sample run:
|
User types "apple" in the InputBox:
|
The item is found in the combo box and selected:
|
Note: This exact same technique can be used to match on an ItemData entry in the list. For example, the code could be modified to accept a number, then you could loop through the combo box entries looking for an ItemData entry that matched that number. The check could be done with a statement similar to If cboFood.ItemData(intX)) = MyNumericEntry Then ...
The cmdDetermine_Click Event
The purpose of the code behind the cmdDetermine button is to show how you determine and obtain the value of the item that has been selected in the combo box. Again, our friend the ListIndex property is used. The value of the text portion of the selected item is given by ComboBoxName.List(ComboBoxName.ListIndex). If there is a corresponding ItemData item, that value is given by ComboBoxName.ItemData(ComboBoxName.ListIndex).
Private Sub cmdDetermine_Click()
If cboFood.ListIndex = -1 Then
MsgBox "There is no item currently selected.", _
vbInformation, _
"Combo Box Demo"
Exit Sub
End If
MsgBox "You have selected " & cboFood.List(cboFood.ListIndex) & "." & vbNewLine _
& "It has " & cboFood.ItemData(cboFood.ListIndex) & " calories.", _
vbInformation, _
"Combo Box Demo"
End Sub

The cboFood_Click Event
The purpose of the code behind the cboFood_Click event is to show that the value of the selected items can be obtained as soon as the user selects it from the drop-down list. This behavior can be examined by first checking the chkAuto checkbox, then by selecting an item from the cboFood combo box.
Private Sub cboFood_Click()
If chkAuto.Value = vbChecked Then
Call cmdDetermine_Click
End If
End Sub
Next, we will look at the code dealing with the Dropdown Combo style of the combo box.
The cmdLoadStateAbbrevCombo_Click Event
This event loads the cboStateAbbrev combo box with U.S. state abbreviations from a comma-delimited sequential file called STATES.DAT. The records in the file contain two fields, the state abbreviation and state name; only the abbreviations are loaded into the combo box. No values are added to the optional ItemData property array of the combo box. As was the case with loading the food combo box, no item is pre-selected after loading the state abbreviations, so you will not see the entries until you click the arrow on the drop-down box.
Private Sub cmdLoadStateAbbrevCombo_Click()
Dim intStateFileNbr As Integer
Dim strBS As String
Dim strStateAbbrev As String
Dim strStateName As String
strBS = IIf(Right$(App.Path, 1) = "\", "", "\")
intStateFileNbr = FreeFile
Open (App.Path & strBS & "STATES.DAT") For Input As #intStateFileNbr
cboStateAbbrev.Clear
Do Until EOF(intStateFileNbr)
Input #intStateFileNbr, strStateAbbrev, strStateName
cboStateAbbrev.AddItem strStateAbbrev
Loop
Close #intStateFileNbr
MsgBox "State abbreviation combo box has been loaded.", _
vbInformation, _
"Combo Box Demo"
End Sub
The cmdAddNewAbbrev_Click Event
This event shows that with this type of combo box, you can type in a new entry in the textbox portion of the combo box. However, a new entry is not automatically added to the list portion of the combo box. If you wish to do this, you must do so with code, as the code in this event procedure demonstrates. When the "Add New Item to List" button is clicked, this code runs to first check that the item is not already in the list, and if not, adds it.
Private Sub cmdAddNewAbbrev_Click()
Dim intX As Integer
If cboStateAbbrev.Text = "" Then Exit Sub
For intX = 0 To cboStateAbbrev.ListCount - 1
If UCase$(cboStateAbbrev.Text) = UCase$(cboStateAbbrev.List(intX)) Then
MsgBox "Item '" & cboStateAbbrev.Text & "' is already in list.", _
vbExclamation, _
"Combo Box Demo"
Exit Sub
End If
Next
' if we get here, the item entered in text portion is not in the list
cboStateAbbrev.AddItem cboStateAbbrev.Text
MsgBox "Item '" & cboStateAbbrev.Text & "' has been added to the list.", _
vbExclamation, _
"Combo Box Demo"
End Sub

Finally, we will look at the code dealing with the Simple Combo style of the combo box.
The cmdLoadStateNameCombo_Click Event
This event loads the cboStateName combo box with U.S. state names from the same comma-delimited sequential file called STATES.DAT. The records in the file contain two fields, the state abbreviation and state name; only the names are loaded into the combo box. No values are added to the optional ItemData property array of the combo box. As was the case with loading the food and state abbreviation combo boxes, no item is pre-selected after loading the data. However, since the list portion of this style of combo box is visible, you will see the entries after they have been loaded.
Private Sub cmdLoadStateNameCombo_Click()
Dim intStateFileNbr As Integer
Dim strBS As String
Dim strStateAbbrev As String
Dim strStateName As String
strBS = IIf(Right$(App.Path, 1) = "\", "", "\")
intStateFileNbr = FreeFile
Open (App.Path & strBS & "STATES.DAT") For Input As #intStateFileNbr
cboStateName.Clear
Do Until EOF(intStateFileNbr)
Input #intStateFileNbr, strStateAbbrev, strStateName
cboStateName.AddItem strStateName
Loop
Close #intStateFileNbr
MsgBox "State name combo box has been loaded.", _
vbInformation, _
"Combo Box Demo"
End Sub

The cmdAddNewName_Click Event
As was the case with state abbreviation combo box, this event shows that with this type of combo box, you can type in a new entry in the textbox portion of the combo box. However, a new entry is not automatically added to the list portion of the combo box. If you wish to do this, you must do so with code, as the code in this event procedure demonstrates. When the "Add New Item to List" button is clicked, this code runs to first check that the item is not already in the list, and if not, adds it.
Private Sub cmdAddNewName_Click()
Dim intX As Integer
If cboStateName.Text = "" Then Exit Sub
For intX = 0 To cboStateName.ListCount - 1
If UCase$(cboStateName.Text) = UCase$(cboStateName.List(intX)) Then
MsgBox "Item '" & cboStateName.Text & "' is already in list.", _
vbExclamation, _
"Combo Box Demo"
Exit Sub
End If
Next
' if we get here, the item entered in text portion is not in the list
cboStateName.AddItem cboStateName.Text
MsgBox "Item '" & cboStateName.Text & "' has been added to the list.", _
vbExclamation, _
"Combo Box Demo"
End Sub

Download the project files for the combo box demo program here.
*** BONUS MATERIAL ***
ComboBox Procedures
Presented below are several examples of how to extend the functionality of the combobox.
Extend the Number of Items Displayed
By default, when you click the drop-down arrow of a combo box, VB will display a maximum of eight items. This example shows how you can set up the combo box to display as many items as you want when the drop-down arrow is clicked.

Download the project files for this example here.
Extend the Width of the Drop-Down List
By default, the drop-down list of a combo box is the same width as the combo box itself. This example shows how you can set up the combo box so that the width of the drop-down list is as wide as the widest item in the list.

Download the project files for this example here.
Automatically Drop Down the List when ComboBox Receives Focus
This example shows how you can automatically display the drop-down list (as opposed to having the user click the drop-down arrow) when the combo box receives focus.

Download the project files for this example here.
Creating a "Multi-Select" Checkbox-ComboBox
This example shows how you can simulate a combo box where the items in the drop-down list have checkboxes, enabling you to make multiple selections. The multiple selections are shown comma-delimited in the text portion of the combo box. This example does not actually use a combo box the text portion is actually a picture box containing a label and a graphical-style command button for the drop-down arrow. When the command button is clicked, a checkbox-style listbox is displayed.

In this sample program, when you click the "Show Selected Items" button, a message box is displayed, showing both the items that were selected, as well as the corresponding ItemData items, both "as is" as well as enclosed in quotes.

Download the project files for this example here.
Search-As-You-Type ComboBox
This example shows how you implement "search-as-you-type" functionality with a combo box. As you type characters in the textbox portion of the combo box, the first item in the list that starts with those characters will be selected. In the screen shot below, as soon as the user types "o" in the box, "onion rings" is selected. This example limits the user to items contained in the list.

Download the project files for this example here.
Search-As-You-Type ComboBox (Enhanced Database Example)
This example extends the "search-as-you-type" functionality demonstrated in the previous example by using database lookups, and this implementation does NOT limit the user to the items contained in the list. If the user types in an item that is not already in the list and clicks the Refresh button, the new item will show up the next time the list is dropped down (i.e., the new item will be inserted into the database table).

A couple of options can be used to modify the behavior of the combo box. You can choose to have the program load items based on the first letter typed (i.e., as shown in the screen shot above, when you type the letter "B", load only the companies that start with the letter "B"). This option makes sense when you are selecting values from a large database table. Alternatively, you can choose to have the program load all values from the database table at once. That option would be suitable for smaller tables.
Also, you can choose whether or not you want the drop-down box to be displayed as soon as focus is moved to the combo box.

Download the project files for this example here.
using combobox
in doing project in vb TIME TABLE MANAGEMENT for tat i'm using list of names in 5 combo box. just think 5 list available in tat combo box... if i select any name in tat first combo box then tat name should not be repeated in remaining combo box tat its help me plz
congrate
your tutorials have really pushed me up.many thanks
can u create a music compiler
can u create a music compiler w/ search by categories: title artist and genre or year
and have a label box that i choose a 1 song
u will see this detail
title
artist
duration
genre
year
combobox dropdown list
if i add recordset adodc1 by connection string table. add data sourse to combobox one field. it will not show in combo box as list why?
mysql
I want to write a code inwhich data will be written by user in combobox bot it would not be a numerical value, a warning should be diseppear in the case of numerical value. And data which written in combox should be saved in MySql.
help me
Respected Sir,
i want to use two combo boxes named "state" and second is "city"
if i select city as "maharashtra" then corresponding cities will be appeared in second combo box.
i try my best but it doesn't working ....
can you help me sir please !!!!
thank You....
combobox help regarding selected text
Respected Sir,
i want to use two combo boxes named "state" and second is "city"
if i select city as "maharashtra" then corresponding cities will be appeared in second combo box.
i try my best but it doesn't working ....
can you help me sir please !!!!
thank You....
you have to dynamically load
you have to dynamically load combo box based on selection of state.
Eg.
if you loading cities from database add the field state as well. Then when user selected state combobox, set recordset to select only cities with belong to that particular state and then fill the combobox with that record set.
this will work.
cheers
Joshi
how can i connect vb6.0 to
how can i connect vb6.0 to oracle9i. m thinking to go for dsn less oledb. Please guide me
Display list in list
how to display a list of items using query,
list of items is in combo box,
need to be displayed in listbox,
eg:if A is selected in combo box
all the items under A in database must be sorted in list box....
fields in db
ID LET
1 A
2 Apple
3 A.....
.
.
21 B
22 Ball
how to change the height of combobox
how to change the height of combobox
i wrote a functin to change the position of text ox and combo box to the position of entered cell in msfexgrid and i also change the hight and the width but the problem the hieght property for the como box is read oly
how can i use winapi or what ever to change the hieght of the combo box
adding data from database in visual basics 2008
i want to use the last saved data in database for further calculation in a form as i saved no.44 and later on i want to add more 22 in it if there are some
more data columns in that database how i will do it please help. i am working with visual basics 2008 ver.
combo box error
hi Guys,
I need a help for some error wherein i used combo box. i entered values thorugh properties under list, however if i enter 4 values, only 3 values are reflecting. Anyone can give some ideas to solve this problem.
Thanks in advance!
solution
hey dr! i think u were doing some mistake. I will tell u the solution,
first u create a form then
select a combo box then
goto its properties then
select list option from the properties then
type your data in this list. if u want to enter more data then press ctrl+enter key then
ur data will be added to the combo box.
U can also do this through coding.
open code section,
here is ur code:
private sub Form1_Load()
combo1.additem("apple")
combo1.additem("orange")
combo1.additem("banana")
combo1.additem("mango")
combo1.additem("guava")
combo1.additem("grapes")
end sub
that's it..................thank u.
i hope tis will work.
can u put the combo1.additem
can u put the combo1.additem into 1 script ?
not
private sub Form1_Load()
combo1.additem("apple")
combo1.additem("orange")
combo1.additem("banana")
combo1.additem("mango")
combo1.additem("guava")
combo1.additem("grapes")
bou make something like this ( it only don't work)
combo.additem("apple,orange,banana,mango,guava,grapes") or something
can u plz tell me how to add
can u plz tell me how to add data in combo-box through text-box ??????
combox1.add(textbox.text)
combox1.add(textbox.text)
Saving changes to a combo box within a form
I know this may sound wierd, but is there any way to save changes to the contents of a combo box within a program from within a form itself, without using external resources like a text file or database?
Thanks in advance.
How to select the option in droop down box
can you tell me how to select the option in dropdown list which is already added using VB Script.
how to load the fields in combo box?
how to load the fields in combo box? please, help me.
after u have created the
after u have created the combo box in the form
go to the properties of the combo box u can do this even by righ clicking on the combo box
then in the properties select the List (which is in the Alphabetic tab)
this is a drop down box where u have to ener the values their
it takes in one value at a time when u have to enter another value u have to do it once again
and do it untill u wish
and then execute the program
u can find all the text that you have entered in ur combobox
all the best
Does anyone know how to get
Does anyone know how to get the input from a textbox and make that many input boxes show up?
I need to do this problem...
Create an application that allows the user to enter the number of rooms to be painted and the price of the paint per gallon. The application should use input boxes to ask the user for the square feet of wall space in each room.
Use a loop e.g. Private Sub
Use a loop
e.g.
Private Sub Command1_Click()
Dim rooms as variant
Dim noofRooms As Integer 'number of rooms
Dim roomArea() As Single 'array for area of rooms
Dim paintPrice As Single 'price of paint per gallon
Dim paintSquareFeet as Single 'paint required per square feet of wall (in gallons)
Dim totalArea as single
Dim totalPaint as single
Dim totalPrice as single
Dim i as integer
totalArea = 0
paintPrice = InputBox("Enter price of paint per gallon")
rooms = InputBox("Enter number of rooms")
PaintSquareFeet = InputBox("Enter amount of paint required per square feet")
If IsNumeric(rooms) And rooms>0 Then
noofRooms = rooms
ReDim roomArea(noofRooms-1)
For i = 0 To noofRooms - 1
roomArea(i) = InputBox("Enter Area of room " & i+1 & "(in square feet)")
totalArea = totalArea + roomArea(i)
Next
totalPaint=totalArea * paintSquareFeet
totalPrice=paintPrice * totalPaint
MsgBox "The total area of the room is " & totalArea & "square feet" & VbCr _
"The amount of paint required is " & totalPaint & " gallons." & VbCr & "The price of the paint required is " & totalPrice & ".", VbOKOnly _
+VbInformation, "Results"
Else
MsgBox "the number of rooms must be a positive integer", VbOkOnly
End If
End Sub
The array is not necessary unless you want to display the individual room areas. Also some errors can occur if you input invalid data. You didn't mention the amount of paint required per square meter, so the user has to input it himself. I did this online so there may be mistakes; nothing you can't correct anyway.
God bless you!
using variable in ComboBox name
I want to use a variable in a ComboBox name so I can fill 10 Combo boxes with data from another worksheet.
The line which does not work is:
The name of the first ComboBox is CC_towarBox1
ct = 1
Worksheets("Catering Card").OLEObjects("CC_towarBox" & CStr(ct)).Object.Value = Worksheets("Data").Cells(Counter_Vd, 5)
If I didn't need to use a variable, then this is simple:
CC_towarBox1.Value = Worksheets("Data").Cells(Counter_Vd, 5)
except then I can't use my look to fill Combo boxes 1 through 10.
On my code, I get the error message
Unable to get the OLEObjects property of the Worksheet class
Please Help.
How to select few records from access and display in vb6?
hey guys, i have been working on a few forms lately, and ive just found myself stuck, i don't know what to do.
i have a table called flight_details which has fields , 1. flight_no 2. flight_name 3. departure_from 4. to 5. rate 6.travelling_class
my project is basically a small scale travel agency experiment. so the table contains 200 records with flight_no as primary key and 5 destinations, and i have estimated the rates.
so now i have a flight form in vb6 which has the same fields, 2. flight_name 3. departure_from 4. to 6.travelling class are comboboxes,
what i want is, when i choose departure_from, to, flight_name and travelling_class, i want the recordset to automatically pick up the corresponding record from the table on the basis on the 4 comboboxes, and display the flight_no, and rate automatically.
now guys, im stuckkkk, please help????
thnx, - Faiz.
How to sort a table using combobox
please help me on my project, i just want to ask you guys on how to sort my records in my access table in vb6.0, i am making a enrolment system and using databoundgrid and data control to connect my access table, i want to view my table according to the combox,
example, if my item in combobox is Freshman, it should be freshmen first, i want them to be sorted out..
Get data from MS Access and use it in Combo Box
Hi, I'm begineer vb6 user, I need to know how can I get or connect MS Access table and show any field's data by using Combo Box? Pls help...
If possible pls mail me a sample code to:
ehsan.haque@gmail.com
Pass selected value to another combo box
I'm developing some forms that have several combo boxes. If the user selects a particular item from the first combo box (e.g. "100%"), I want the other combo box selections to appear with a default value (e.g. "n/a" or "Not required"). How can I pass this value on to the other combo boxes so that the user can see the value?
how to apply an array in
how to apply an array in combo box?when i run the program, the message box said that procedure declaration does not match description of event or procedure having same name.actually i already create combo box in previous(without array) and the next form,i wanna apply array.
when i run the program with combo box array, the result is not appear for every single combo box.please help me
Private Sub form_load()
For i = 0 To nopipe
cboCvalue1(i).AddItem "ABS - Acrylonite Butadiene Styrene"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 130
cboCvalue1(i).AddItem "Asbestos Cement"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 140
cboCvalue1(i).AddItem "Brick sewer"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 95
cboCvalue1(i).AddItem "Cast-Iron - new unlined (CIP)"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 130
cboCvalue1(i).AddItem "Cast-Iron 10 years old "
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 110
cboCvalue1(i).AddItem "Cast-Iron 20 years old"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 95
cboCvalue1(i).AddItem "Cast-Iron 30 years old"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 83
cboCvalue1(i).AddItem "Cast-Iron 40 years old"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 73
cboCvalue1(i).AddItem "Cast-Iron, asphalt coated"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 100
cboCvalue1(i).AddItem "Cast-Iron, cement lined"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 140
cboCvalue1(i).AddItem "Cast-Iron, bituminous lined"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 140
cboCvalue1(i).AddItem "Cast-Iron, sea-coated"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 120
cboCvalue1(i).AddItem "Cast-Iron, wrought plain"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 100
cboCvalue1(i).AddItem "Cement lining"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 135
cboCvalue1(i).AddItem "Concrete"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 120
cboCvalue1(i).AddItem "Concrete lined, steel forms"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 140
cboCvalue1(i).AddItem "Concrete lined, wooden forms"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 120
cboCvalue1(i).AddItem "Concrete, old"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 105
cboCvalue1(i).AddItem "Ductile Iron Pipe (DIP)"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 140
cboCvalue1(i).AddItem "Ductile Iron, cement lined"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 120
cboCvalue1(i).AddItem "Fiber"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 140
cboCvalue1(i).AddItem "Fiber Glass Pipe - FRP"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 150
cboCvalue1(i).AddItem "Metal Pipes - Very to extremely smooth"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 135
cboCvalue1(i).AddItem "Polyvinyl chloride, PVC, CPVC"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 130
cboCvalue1(i).AddItem "Smooth Pipes"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 140
cboCvalue1(i).AddItem "Steel new unlined"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 145
cboCvalue1(i).AddItem "Steel, corrugated"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 60
cboCvalue1(i).AddItem "Steel, welded and seamless"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 100
cboCvalue1(i).AddItem "Steel, interior riveted, no projecting rivets"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 110
cboCvalue1(i).AddItem "Steel, projecting girth and horizontal rivets"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 100
cboCvalue1(i).AddItem "Steel, vitrified, spiral-riveted"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 100
cboCvalue1(i).AddItem "Steel, welded and seamless"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 100
cboCvalue1(i).AddItem "Tin"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 130
cboCvalue1(i).AddItem "Vitrified Clay"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 110
cboCvalue1(i).AddItem "Wrought iron, plain"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 100
cboCvalue1(i).AddItem "Wooden or Masonry Pipe - Smooth"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 120
cboCvalue1(i).AddItem "Wood Stave"
cboCvalue1(i).ItemData(cboCvalue1(i).NewIndex) = 115
Next i
End Sub
Private Sub cboCvalue1_Click()
txtcoefficient(i).Text = CStr(cboCvalue1(i).ItemData(cboCvalue1(i).ListIndex))
End Sub
Private Sub cmdselect1_Click()
MsgBox "C value combo box has been loaded.", _
vbInformation, _
"Combo Box Demo"
End Sub
vb6
hi
I am not programmer but I like vb so much...
1) Put a "0" in the CboCvalue's Index property
2) Private Sub cboCvalue1_Click()
this is wrong as you are calling Index property's index value
hence the calling method should be
Private Sub cboCvalue1_click(index As Integer)
txtcoefficient(i).Text = Str(cboCvalue1(i).ItemData(cboCvalue1(i).ListIndex))
End Sub
'Thoothukudi, TN, India
I CAN'T GET THIS TO WORK
I am so frustrated. If i copy paste this into my visual basic and hit run it pops up a blank box with what looks to be a drop down (although the drop down works).
I am a BEGINNER trying to figure stuff out and having problems pasting code into visual basic for word.
I have spent several days on this.
PLEASE HELP
To what. Let us not be subjective here.
try barking at the moon - you will get the same result.
Make sure your combobox name
Make sure your combobox name match the one in the code and make sure you call your combobox populating code from the form load event!
thesis
code of combo box for month,date and year. help please
e-mail
can u answer this?
the command should Remove all items from the ComboBox by clearing it and adding it all to a listbox.
drop down list
Can I know how to make a new data that we enter under the AddItem method to be saved permanently in the drop down list?
I'd use database to store
I'd use database to store and add the items and then when selecting the items(populating combobox from DB), use DISTINCT in the query string.
how combobox loads data from access table
hi
i really really need your help..i'm using vb 2008 n connected it to access 2007.
how can i get the combobox to load data from the access table ??
thank you!
So your DB connection is OK.
So your DB connection is OK. If you use OleDB, you do a DB query where you SELECT dbCol FROM table, or whatever you want. Then set the data source for your combobox:
Me.cmbBOX.DataSource = DSet.Tables(0)
Me.cmbBOX.ValueMember = "dbCol"
Me.cmbBOX.DisplayMember = "description"
Combox Itemdata in run-time
Hi,
I use a ADO recordset to fill a combobox with a TEXT (an Address form in SQL to be 1 field) in the list and ID in the itemdata on the form load.
I got a command button that popup and other form for either modification of current seleted address or a creation of an new one.
on that
I build an Form object,
verify if it was saved, then clear the combobox and rerun the Recordset to reload address list of my customer,
If I run it in step-by-step, the combo box reload with modified list correctly, on run-time : it will not update correctly.
I used combox.clear to clear the list, and reload it with recordset.
can someone explain to me why it works on step-by-step, but not in real time ?
Regards
How can be send data of one form to another form?
Sir,I am beginner of vb6 programming.I need help on this topic.Pls help me..........
send data from one form to another
you could do something like that "nameofform.nameof textbox.text=nameofform.nameoftextbox.text"
for e.g form1.txtname.text=form2.txtclientname.text
when you're using combo box
when you're using combo box ... then you choose one... in the list how do you diplay it on the display label.... pls need help
COMBO BOX WITH AUTOCOMPLETE FILEN NAME
HIGHI EVREYBODY
I Need Code OR ActiveX COMBO BOX WITH AUTOCOMPLETE FILE NAME LIKE WINDOWS RUN DIALOG OR EXPLORE ADRESS
THAK YOU
Stop AutoSelection
I am having a problem with a combobox and entering the string with a bar code scanner.
It appears that the issue is being caused by the selctions being added into the display box as the string is added by the bar code reader. I want the string added to the input box without the selections from the list at least until the string is complete. Is there a way to disable this autocomplete or list selection complete?
Using a combo box in a calculator
Hello all, hope some one can help me? I'm trying to use a combo box in a calculator. There are two text boxes that are to be multiplied and a third box shows the answer. So if the input to text box 1 is 2 and the input to text box 2 is 6 then normally the answer would be 12. Text box 1 & 2 are to have combo boxes placed next to them to show units i.e. micro, milli, centi, kilo & mega. So if text box 1 uses milli units and text box 2 uses mega units the answer then will be 12000 (0.002 x 6000000). I'm not sure how to assign the units to the text box so the user can type 2 in and then select milli from the list of units to achieve the required answer, can anyone help? Thanks
related to combox
i do need some help related to combox:
1) m making my project and in that have used combox for selecting various options and had inserted the item , suppose i had entered MBA, BCA, MCA, B.E.
in the begging i have used database to enter marks per semester(i.e. upto 8th sem) now my problem arises that some have courses for 3 year(means upto 6th sem) some have courses for 4 year(upto 8th sem) how to disable the text boxes which have course upto 3 year only or less.
2)how to restrict the marks to be entered upto 100
Do help me with relevant code.thnx in advance
MoveWindow
In case anyone runs across this, the MoveWindow API doesn't work properly when moving a combobox on the SSTab control.
http://www.xtremevbtalk.com/showthread.php?p=988558
http://support.microsoft.com/default.aspx?scid=kb;EN-US;187562
These articles do not hit on the problem directly, but give you an nudge in the right direction.
I ended up just storing the
I ended up just storing the .Top and .Left of the ComboBox and the last thing the procedure does is set the .Top and .Left of the control back to the original.
i need a code for
i need a code for automatically detection of peripherals attach(i.e printer,scanner)can you help me?
thanks
.net
i want to no hw to write for combobox
how combobox loads data from
how combobox loads data from access table and how we can enter another text under combobox data in same table. plz tell me how it done .
thanx in advce
list box or combo box with pull down menu
I have a working VB program but I need to add a selection of items that can be selected by the operator. I do not have to be able to enter any new items in the list only select from the list. I would like to only show one line on the form to save space and when the list box is selected then I could pull down the rest of the box so I could see all the members in the box. I cannot seem to understand how to do this. Can you help me? Once an item is selected I want to set a paramter associated with that item so I can use it for look up later.
Thank you
adding the value in the itemdata
Hi, I've just read your combobox information. the question that I have is it possible to add the value of index . like with the lines below .
cboFood.AddItem "Orange"
cboFood.ItemData(cboFood.NewIndex) = 60
cboFood.AddItem "Apple"
cboFood.ItemData(cboFood.NewIndex) = 80
cboFood.AddItem "Banana"
how can I add the value in cboFood.ItemData(cboFood.NewIndex) = 60 and the value in cboFood.ItemData(cboFood.NewIndex) = 80 together and store it in another variable. thanks
abt combobox
plz help.....i hv to develop one govt project..in tht m using two comboboxes....both wl be connectd to access....through adoc i hv connectd...in the output if i select taluk name in the first combo....autometically it has to display villages tht r cmng under tht taluk....but it is displaying all the villages tht r in table.....i need solution for tht.....tel me hw to use filter property for tht.............
thank you
index in combobox
Do index in combo box have maximum limitation in case we always add item to them and never clear ?
Pls i need a help
I created a database with access 2007, how can i retrieve my data through adodc in vb6, it's giving me error about the file format not supported and i don't know where to get access 98 to create the database
re
HI.
You can in Microsoft access change database format do access 98.
Tools/Database Utilities/Convert Database.
Vlad
how combobox loads data from access table
how combobox loads data from access table and how we can enter another text under combobox data in same table. plz tell me how it done .
thanx in advce
come on budy.....................
HI, i need to know if this
HI,
i need to know if this is possible
combobox1(select an item/word)
||
Access(searches for a database that matches the selected item/word from the combox1
||
combobox2(matched items/word from access are the only ones being displayed)
Need help, thank you!!!
yes, have the same problem.
yes, have the same problem. except mine need to use VB6.
Also want to know if once matched, can it automatically in a notepad or another access database then print it as a datagrid?
those who can help, thank u. I appreciate it very much
combobox in vbnet
hello, can anyone help me with my project in vb.net. My teacher asked us to create a vb.net project using 3 combo boxes. One for month, date and year.
then there will two labels that will display the zodiac sign and the astrology year selected from the combo boxes. i really don't know the code so please help me, I will appreciate your response very much..
If there are a lot of combo
If there are a lot of combo boxes on the form. It’s also not efficient for high speed data entry, like using TAB to move through controls and the number pad or arrow keys to select answers. With just a few lines of code, you can make your combo boxes drop down automatically when the cursor enters them. I’ll show you two ways to accomplish this..
hi!
thank you!!! because of you one of my thesis prob is solved love lots! and godbless! godspeed !
Thank you very much for
Thank you very much for sharing your valuable resources....
combo box
i have a project in that 2 combo boxs are there . In first combo box 3 options are there under each option five sub options are there when i want to select first option the five option should be display in second combo box . When i select the second option that five sub options should be displayed in second combo box. Sir Reply me.
MoveWindow
I placed an SSTab on a form, dropped a frame on the first tab and then placed a combo box. When the Call MoveWindow(pobjCombo.hwnd, pt.X, pt.Y, pobjCombo.Height, lngNewHeight, True)
code is executed from the SetDropDownHeight sub, the combo box is totally displaced. Any suggestions to keep the top and left as-is? Thank you.
very useful
very useful tutorial
basically i was looking for such functionality in my project, and now i am thinking that my surfing time is utilized.
thank you very much
Very helpful for amateurs
Hi,
This tutorial is very helpful for amateurs like me. Thanks a lot.
How to display a corresponding Text of combobox to lable
I could open the database and recordset.
now on combo1_click() if I'll select the particular item then the corresponding value of that particular item should be displayed on lable.
can any help me?
Post new comment