Solved

Put this in a listbox .

Posted on 2004-09-29
2
306 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
[X]
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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

749 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