Solved

How to add data to ListBox in VB 6.0

Posted on 2004-07-30
7
596 Views
Last Modified: 2007-12-19
I need code for it.

Thanks
0
Comment
Question by:Mike Eghtebas
7 Comments
 
LVL 8

Accepted Solution

by:
bramsquad earned 200 total points
ID: 11680602
try this

        Dim i As Integer 'index
        listbox.AddItem("name", i)

~b
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 11680611
You use the AddItem method:

i.e.
 
    Dim i As Integer

    For i = 1 To 10
        Listbox1.AddItem "Item " & Cstr(i)
    Next i


Hope this helps.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 11680629
List1.AddItem "New Entry"
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:danielluyo
ID: 11680650

List1.AddItem "Item1"
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 11680701
Maybe I could read it from a backend table, could you please check following code:

Suppose connection to mdb and SQL string are taking care of
.
.
Dim i as integer
if rs.recordcount>0 then
rs.movelast      '<-- I need VB version, this is Access code
i=recordcount
rs.move first     '<-- I need VB version, this is Access code
Do Until rs.eof
listbox.AddItem(rs("FieldName"), i)

rs.movenext        '<-- I need VB version, this is Access code
Loop
end if
.
.

Thanks,

Mike
0
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 200 total points
ID: 11680745
That code looks fine.  You can remove all of the   '<-- I need VB version, this is Access code lines.  The VB code is exactly the same.
0
 
LVL 8

Expert Comment

by:bramsquad
ID: 11680847
if there are errors coming up, make sure you have a reference to adodb
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

740 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