Results 1 to 10 of 10

Thread: Listbox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    153

    Post

    I have a listbox that retrieves data in a comma delimited format. How can display the data in the listbox in a column format. Currently, all data is displayed in one column. I want to partition the listbox in a grid like fashion.

    Thanks!

  2. #2
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    As far as the columns in your listbox, I know there have been some posts on here a while ago about that, try searching for them (search button at top of page). But I think it has something to do with setting "tabs" in your listbox. Sorry I couldn't help more, but that should give you somewhere to start.

    ------------------
    Ryan

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Why not use a grid?

    ------------------
    Marty
    COGITO EGGO SUM
    I think; therefore I am a waffle.

  4. #4
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308

    Post

    Hi, Hutty.

    You can do it only using Tab, but it won't look nice. It's better to use Grid control or listview. But you can try.

    rs.MoveFirst
    Do Until rs.EOF
    List1.AddItem rs.Fields(0) & vbTab & rs.Fields(1) & vbTab & rs.Fields(2)
    rs.MoveNext
    Loop

    Larisa

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    153

    Post

    Thanks guys for your responses. I didn't mentioned before that the data is not being retrieved from your conventional access database. I'm accessing one of the .dll files from our financial software using "Application Program Interface (API)".

    It looks like the Grid would be my best option, but nothing happens when insert where list1 is located in code. I believe I'm not using the DBGRID function correctly. Any code on how to use the dbgrid instead of listbox in code.

    Thanks!

  6. #6
    Addicted Member
    Join Date
    Jan 2000
    Location
    Fresno, California, USA
    Posts
    195

    Post

    The listbox idea is very workable. By using report view with subitems you can create columns of any width.

    dim clmx as columnheader
    dim itmx as listitem

    set clmx = listboxname.columnheaders.Add(index, key, TEXT, WIDTH, alignment, icon)
    ' add a column header for each column
    set itmx = listboxname.listitems.add(index, key, TEXT, icon, smallIcon)
    itmx.subitems(1) = nextcolumn
    ' add a subitem for each additional column

    Good luck.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    153

    Post

    HDR,

    This is what the return string looks like in the list box.

    LFDIV,FY_PREMIUM.STAT_INP,833942,1600819,2479545,653
    LFDIV,REN_PREMIUM.STAT_INP,2225176,4551447,6792469,5131
    LFDIV,SP_PREMIUM.STAT_INP,1765550,3273375,4654127,0
    LFDIV,INW_PREM.STAT_INP,98397,186944,397835,149
    LFDIV,OUTW_PREM.STAT_INP,472102,667209,863370,3088
    LFDIV,RET_PREM_G.GAAP_ADJ_INP,-1615228,-3264710,-4812230,0
    LFDIV,RET_PREM_G.GAAP_TL_INP,29435,148182,-68583,0
    LFDIV,NIINCOME.STAT_INP,999352,2038943,2839070,585
    LFDIV,NII_INC_ASSO.STAT_INP,1382,3771,7712,0
    LFDIV,NII_FIN_SERV.STAT_INP,2675,4964,6493,0
    LFDIV,NII_DIVELIM_DOM.STAT_INP,-40,-81,-126,0
    LFDIV,NII_DIVELIM_FOR.STAT_INP,-1961,-3921,-6110,0


    Is the code you provided workable as it relates to the above/

    Thanks!

  8. #8
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670

    Post

    If you want to store stuff in a grid that isn't in a database you can a) spend hours of pain and anguish trying to use DBGRID or b) buy Apex TrueDBGrid from www.ApexSC.com and use the XArray object which you can populate with any data you like and then bind it to a grid as if it was a database.


    ------------------
    Mark "Buzby" Beeton
    VB Developer
    [email protected]



  9. #9
    New Member
    Join Date
    Jan 2000
    Location
    Oregon House, CA,
    Posts
    8

    Post

    If you have a lot of data, you might want to investagate importing it into an Access table and then exporting the table to VB.

    A while ago I transferred all the data from a 4th dimension database to an Access database, and the raw data looked exactly like yours.

    If I remember correctly, Access had no trouble separating the comma delimited data into different fields.

    Of course, this depends on the project. If you're talking about a one time deal, then the Access idea might work. If it's something your program would do all the time, then it's different.

    WillP


  10. #10
    Addicted Member
    Join Date
    Jan 2000
    Location
    Fresno, California, USA
    Posts
    195

    Post

    Yes, it is very workable. Do the 'clmx =' thing six times to set you columns and headers (once for each column.) Do the 'set itmx =' thing once per row. You can use an index for the row, or you can build a key (must have at least 1 alpha character.) Your data for the first column goes here. Then for the other five columns, use the 'itmx.subitems(column) =' thing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width