Solved

How to add data to ListBox in VB 6.0

Posted on 2004-07-30
7
594 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
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.

 
LVL 3

Expert Comment

by:danielluyo
ID: 11680650

List1.AddItem "Item1"
0
 
LVL 33

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

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

895 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

13 Experts available now in Live!

Get 1:1 Help Now