Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Put this in a listbox .

Posted on 2004-09-29
2
305 Views
Last Modified: 2013-12-25
   If Not RsType.EOF Then
            With ctrControl
                Do Until RsType.EOF
                    .AddItem Trim(RsType("Book"))
                    .AddItem Trim(RsType("cost"))
                    .AddItem Trim(RsType("list"))
                   .ItemData(.NewIndex) = RsType("id")
                    RsType.MoveNext
                Loop
            End With
        End If
I have this achieve but it is displaying in the listbox incorrectly.

The question is how to put the resultset in each column in a listbox
0
Comment
Question by:zachvaldez
  • 2
2 Comments
 
LVL 8

Accepted Solution

by:
mladenovicz earned 125 total points
ID: 12180896
you should use listview control, not listbox
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 12181013
or you can set fixed length font (e.g Courier New) for list box, and try sthg like this
const MaxLen =15

   If Not RsType.EOF Then
            With ctrControl
                Do Until RsType.EOF
                    .AddItem m_FormatItem(RsType("Book"), maxLen) & "|"  & m_FormatItem(RsType("cost"), maxLen) & "|" & m_FormatItem(RsType("list"), maxLen)

                   .ItemData(.NewIndex) = RsType("id")
                    RsType.MoveNext
                Loop
            End With
        End If

Private Function m_FormatItem(Itm As String, ItemLen As Integer) As String
    m_FormatItem = Trim(Itm) & Space(ItemLen - Len(Itm))
End Function

where maxlen is "column" width - you have to be sure that string from rs is not larger than maxlen
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

856 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