• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 603
  • Last Modified:

How to add data to ListBox in VB 6.0

I need code for it.

Thanks
0
Mike Eghtebas
Asked:
Mike Eghtebas
2 Solutions
 
bramsquadCommented:
try this

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

~b
0
 
Carl TawnSystems and Integration DeveloperCommented:
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
 
GrahamSkanRetiredCommented:
List1.AddItem "New Entry"
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
danielluyoCommented:

List1.AddItem "Item1"
0
 
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
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
 
Carl TawnSystems and Integration DeveloperCommented:
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
 
bramsquadCommented:
if there are errors coming up, make sure you have a reference to adodb
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now