How to add data to ListBox in VB 6.0

I need code for it.

Thanks
LVL 34
Mike EghtebasDatabase and Application DeveloperAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
bramsquadConnect With a Mentor Commented:
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
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.

 
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 TawnConnect With a Mentor Systems 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.