Solved

How to add data to ListBox in VB 6.0

Posted on 2004-07-30
7
595 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA error replacing data 6 39
A macro to Count the number of rows across all worksheets 3 94
Excel Automation VBA 19 70
Error with a code discussed on this page 5 13
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.
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 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…

770 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