VB 6.0 Listbox

G

Guest

I have gotten my databound listbox to select a record from my database using
the primary key field. What I would like to do now is get the listbox to
display more than one field in it such as the following:

primarykey.visible = false, LastName, FirstName

So that my listbox will look like this:

Allen Frank
Doe John
Smith Joe

How do I accomplish this??
 
G

Guest

August 8, 2004

I am not quite sure whether you are using a VB 6.0 Listbox
or a .Net...

You could use a datareader to select the records from the
database and then cycle through them, creating a new item
as you go...

While Reader.read
Listbox1.items.add(Reader(0).ToString & " " & _
Reader(1).ToString)

' Assuming that Reader(0) = the firstname and
' Reader(1) = the lastname

End While

In the Intellisense for the reader, the ToString method will not
appear, but if you type it out, it will work. If you are using a 6.0
control, I hope that some of this can be applied to that version,
as I do not have experience with 6.0. Have a nice day!


Joseph MCP
 
J

Jeff Johnson [MVP: VB]

If this is a VB6 question, please ask it in one of the microsoft.public.vb.*
groups. This group is for VB.NET.

I recommend microsoft.public.vb.controls,
microsoft.public.vb.controls.databound, or
microsoft.public.vb.general.discussion.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top