Solved

Multiple columns ComboBox and ListBox

Posted on 1998-04-13
7
316 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now