Put this in a listbox .

Posted on 2004-09-29
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")
            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
Question by:zachvaldez
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
  • 2

Accepted Solution

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

Expert Comment

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")
            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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add and format columns in vb6 7 84
IF ELSE Statement in Excel Macro VBA 16 102
Set WorkSheet  not Working 9 62
VB6 calling COM DLL written in Visual Studio 2003 6 57
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

734 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