Solved

Multiple columns ComboBox and ListBox

Posted on 1998-04-13
7
318 Views
Last Modified: 2010-08-05
I'm working in vb4. I'm using the Microsoft Forms 2.0 OCX.
I switched a ComboBox to ColumnCount = 2. I'm getting data from a recordset.
How can I do to add items to the first and second columns?
I know how to work with standard ComboBoxes: ComboBox1.AddItem "Hello", but i don't know how to send data to thhe second column, and my help file doesn't work.
How do you work with multiple column comboboxes?
How do you extract items?
Which is the propertie that allows you to do that?
Thanks
Ivan Babic
ibabic@hotmail.com
PD: The same question for ListBoxes, please. I figure out it should be the same, but you never know.
0
Comment
Question by:ibabic
7 Comments
 

Author Comment

by:ibabic
ID: 1461156
Edited text of question
0
 

Expert Comment

by:tapsbin
ID: 1461157
Just wait for few hours...i will answer...

It seems to me that by changing the ColumnCount = 2 ...it is
only a logical second column so that you go on adding items
and it will appear columnwise...

But yes i will clearify you within few hours...

Thanks,

TAPS

0
 
LVL 3

Expert Comment

by:fguerreiro_inix
ID: 1461158
To assign values to an item beyond the first column, use the List or Column property and specify the row and column of the item. I can assign all at a time if do this:
object.additem ValueCol1 & vbtab & ValueCol2 & ......

Extracticon (of the imagelist control) is a method, not a property. You can use it to extract a icon of the imagelist to assign it to a mousepointer for example.
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:ibabic
ID: 1461159
fguerreiro:
I didn't say Extracticon. i said Extract Item from the Combobox or the ListBox.
For example :
If i have this Access TABLE :
     Code                Name
     00001               Ivan Babic
     00002               F. Guerreiro

How can i fill the combo so that any of those values has an exact place in the list? i mean, there should be a propertie in the combobox that lets me extract a value like this:
Msgbox "This is the name : " & ComboBox1(Row(2), Column(2))
and it will show me this :
        This is the name : F. Guerreiro
I don't wanna work anymore with functions like Right(Combobox1,5) in order to get the code of a person. I need to work with column numbers. How can i do it?

Thanks
Ivan Babic
ibabic@hotmail.com
PD : I know how to get the row number back (with listindex). What i need is to get the column number. to use it.
0
 

Expert Comment

by:tapsbin
ID: 1461160
I was confused reagarding the standard combo box and the microsoft forms 2.0 control combo box...

I will have to work it out..Sorry for your waiting...

Thanks,

TAPS

0
 
LVL 5

Accepted Solution

by:
bin_huwairib earned 50 total points
ID: 1461161
ibabic,

AddItem method will add text in the first column only, to use the other columns you must use List property.

Example:

Private Sub Form_Load()
 Dim Index As Integer

 Index = ComboBox1.ListCount
 Call ComboBox1.AddItem("Column1", Index)
 ComboBox1.List(Index, 1) = "Column2"  '1 means the second column
End Sub

You can use the same code for ListBox control.
0
 

Author Comment

by:ibabic
ID: 1461162
bin_huwairib:
I tried what you said, and it works!!!
Now i have another problem.
When i close the project (vb4) and i try to reopen it, it gives me trouble. VB4 tries to open the MsForms 2.0 Combobox as an old one, i mean, as a MsForms 1.0 ComboBox. And of course, it gives me an error like :
Line 218: The Property Size Name of CD_CAMPAÑA is not valid.
Line 220: Couldn't load the Property ColumnCount of CD_CAMPAÑA .
etc...
It's because it's trying to open the combobox as a standard vb4 combo. How can i fix it?
Ivan Babic
ibabic@hotmail.com
PD: Also for ListBoxes
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Write data from SQL to CSV file - position 1 61
How does CurrentUser work? 10 37
Visual Studio search word table and return Cell index 8 61
How to make an ADE file by code? 11 87
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question