New topic: replacing row in a listbox
<http://forums.realsoftware.com/viewtopic.php?t=47378> Page 1 of 1 [ 4 posts ] Previous topic | Next topic Author Message Rivo Post subject: replacing row in a listboxPosted: Sat Mar 23, 2013 12:09 am Joined: Tue Aug 29, 2006 4:04 am Posts: 501 Location: Indonesia Hi, I was trying to replace the name which is located in listbox3 row number 2. and the value is the result of comparing between 2 listboxes. I want to compare listbox1 row number 2 with the listbox4. if its match then replace the row on listbox 3 with the result from listbox4 column 2. The content of the listbox 4 is column 0 , column 1 apple 1 mango 2 orange 3 here is the code dim i as integer dim s as string dim ct As integer = 0 ct=ct+2 s = Listbox1.Cell(ct,0).trim // I use trim to make sure extra spaces don't mess up things if listbox4.ListCount = 0 then exit for i = 0 to listbox4.ListCount -1 if listbox4.cell(i,0).Trim = s then ct=ct+1 Listbox3.AddRow "" listBox3.cell(ct,0)= listbox4.cell(i,1) exit end if next i Timer1.Enabled=false the result is always inserting on listbox1, but I'm expecting in just add it on listbox3 row number 2. this code is placed on a timer. any helps..? thanks Regards, Rivo Top kermit Post subject: Re: replacing row in a listboxPosted: Sat Mar 23, 2013 1:47 am Joined: Mon May 30, 2011 12:56 am Posts: 657 Quote:the result is always inserting on listbox1, No, its adding in listbox 3 There is no code here to add on listbox1 but I'm expecting in just add it on listbox3 row number 2. If I understand you correctly, this is the problem stuff: ct=ct+1 Listbox3.AddRow "" listBox3.cell(ct,0)= listbox4.cell(i,1) exit and it should be listBox3.cell(ct,0)= s exit assuming listbox3 HAS 2 rows at this point. If it does not, then you will need to add Top HMARROQUINC Post subject: Re: replacing row in a listboxPosted: Sat Mar 23, 2013 2:13 am Joined: Sun Jan 25, 2009 5:11 pm Posts: 540 Location: Guatemala, Central America I would probably do it like this: listBox3.addrow "" listBox3.cell(listBox3.lastindex,0)= listbox4.cell(i,0) // Note that listbox4.cell(i,0) <-- changed from (i,1) Or better as kermit suggested: listBox3.addrow "" listBox3.cell(listBox3.lastindex,0)= s // since you know for sure what s contains _________________ Future RS guru. Ride the world! Top Rivo Post subject: Re: replacing row in a listboxPosted: Sat Mar 23, 2013 2:33 am Joined: Tue Aug 29, 2006 4:04 am Posts: 501 Location: Indonesia My mistake, I forgot to delete the code that allowing to inserting on listbox1. really sorry, I have fixed it and its running now.. thanks anyway regards, Rivo Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 4 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
