Link to home
Start Free TrialLog in
Avatar of zachvaldez
zachvaldezFlag for United States of America

asked on

Put this in a listbox .

   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
ASKER CERTIFIED SOLUTION
Avatar of mladenovicz
mladenovicz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mladenovicz
mladenovicz

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