Solved

How to add data to ListBox in VB 6.0

Posted on 2004-07-30
7
593 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

708 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

12 Experts available now in Live!

Get 1:1 Help Now