Combining 2 list boxes into a third - but....

  1. 6 days ago

    David L

    Nov 6 Pre-Release Testers, Xojo Pro

    Hi folks - new to XOJO ( well.... programming in general) and I could use a little listbox help!
    What I have is two list boxes each with data. The first cell in each row is the current date. Each row represents a day of data:
    (maybe slightly ambitious for a first project)

    Thanks for taking a look below! - Dave L.

    listbox 1:
    11/5/19 | data1 | data2 |ect - out to 9 cells

    listbox 2:
    11/6/19 | data1 | data2 | ect out to 9 cells

    I need to put the data from listbox1 and listbox2 into a 3rd listbox, but the rows do not always align with the dates ( if I skip a day for 1 of the listboxes they get out of sync.

    the 3rd table should look lie this:

    11/5/19 | data 1 | data2 | ... | 11/6/19 | dat1 |....

    See below - but there's got to be a better way - this doesn't quite work....

    what I did was make a loop to 'copy' table 1 into table3:

    my variables:
    ///////////////////
    ar col as integer
    var row as Integer
    var end1 as Integer
    var end2 as Integer
    var mdate as string
    var edate as string
    var M( ) as string
    var E( ) as string
    var md as Integer
    var ed as Integer

    end1 = MyADPWindow.EveningList.Listcount-1
    end2 = MyADPWindow.MorningList.listcount -1

    //////////////////////////////////

    // fill ion the first 9 columns from the eveninglist listbox // the listbox1
    for row = 0 to end1 //end1 = EveningList.Listcount-1
    PRN_List.addrow
    for col = 0 to 9
    PRN_List.cell(row,col) =EveningList.cell(row,col)
    next
    next

    then I used split to break out the day of the week and put it in another listbox (mornlist) as reference comparison:

    for row = 0 to end1
    mornlist.cell(row,0) = MyADPWindow.EveningList.cell(row,0) // fill in the evening date in the table on the right of screen
    edate = mornList.cell(row,0)
    E( ) = split (edate,"/")
    mornList.cell(row,2) = E(1)
    next
    /////////////////////////
    ////// fill in the edate row in the mornlist /// listbox to right on report screen
    for row = 0 to end2
    mornList.cell(row,1) = MyADPWindow.MorningList.cell(row,0)//fill in the morning date in the table on the right of screen
    mdate = mornList.cell(row,1) // morning date
    M( ) = split (mdate,"/")
    mornList.cell(row,3) = M(1)
    next

    then I looped through like this:
    if ed + 1 = md then
    for col = 0 to 9
    PRN_List.cell(row,col+10) = MyADPWindow.morningList.cell(row,col)
    next
    elseif ed = 31 and md = 1 then
    for col = 0 to 9
    PRN_List.cell(row,col+10) = MyADPWindow.morningList.cell(row,col)
    next
    elseif ed + 2 = md then
    for col = 0 to 9
    PRN_List.cell(row +1,col+10) = MyADPWindow.morningList.cell(row,col)
    next
    elseif ed + 3 = md then
    for col = 0 to 9
    PRN_List.cell(row +2,col+10) = MyADPWindow.morningList.cell(row,col)
    next
    elseif ed + 4 = md then
    for col = 0 to 9
    PRN_List.cell(row +3,col+10) = MyADPWindow.morningList.cell(row,col)
    next
    elseif ed + 5= md then
    for col = 0 to 9
    PRN_List.cell(row +4,col+10) = MyADPWindow.morningList.cell(row,col)
    next
    elseif ed + 6= md then
    for col = 0 to 9
    PRN_List.cell(row +5,col+10) = MyADPWindow.morningList.cell(row,col)
    next
    elseif ed + 7= md then
    for col = 0 to 9
    PRN_List.cell(row +6,col+10) = MyADPWindow.morningList.cell(row,col)
    next
    elseif ed + 8= md then
    for col = 0 to 9
    PRN_List.cell(row +7,col+10) = MyADPWindow.morningList.cell(row,col)
    next
    elseif ed + 9= md then
    for col = 0 to 9
    PRN_List.cell(row +8,col+10) = MyADPWindow.morningList.cell(row,col)
    next
    elseif ed + 10= md then
    for col = 0 to 9
    PRN_List.cell(row +9,col+10) = MyADPWindow.morningList.cell(row,col)
    next
    elseif ed + 11= md then
    for col = 0 to 9
    PRN_List.cell(row +10,col+10) = MyADPWindow.morningList.cell(row,col)
    next

    elseif ed -2= md then
    for col = 0 to 9
    PRN_List.cell(row -1 ,col+10) = MyADPWindow.morningList.cell(row,col)
    next

    end if

    next

or Sign Up to reply!