New topic: inserting row on last row
<http://forums.realsoftware.com/viewtopic.php?t=47608> Page 1 of 1 [ 6 posts ] Previous topic | Next topic Author Message Rivo Post subject: inserting row on last rowPosted: Tue Apr 16, 2013 1:32 am Joined: Tue Aug 29, 2006 4:04 am Posts: 506 Location: Indonesia Hi, I want to add new row on last row in a listbox. Listbox1.cell(Listbox1.LastIndex1,0)="Total" this code is working, but its replacing the last row. What I need is just add new row on lastindex without replacing last row. any helps.? thanks regards, Rivo Top msssltd Post subject: Re: inserting row on last rowPosted: Tue Apr 16, 2013 2:33 am Joined: Fri Oct 28, 2005 7:05 am Posts: 537 Location: Emsworth, UK Does this help? ListBox1.AddRow "Col0" ListBox1.Cell(ListBox1.LastIndex, 1) = "Col1" _________________ Yes it's me in the avatar Top Rivo Post subject: Re: inserting row on last rowPosted: Tue Apr 16, 2013 3:42 am Joined: Tue Aug 29, 2006 4:04 am Posts: 506 Location: Indonesia Actually I want to add total on the last row every time the button was executed. dim row as integer dim dz as string dim total as double for row= 0 to ListBox1.ListCount-1 total = total + CDbl(ListBox1.Cell(row,5)) next sDiskon.text=Format(total, "-###,##0") if Listbox1.cell(Listbox1.LastIndex,0)<>"Total" then ListBox1.AddRow "Total" end if this is work, but when I need to add new row, the Total should be removed and move to the lastindex again. thanks Rivo Top lavalle Post subject: Re: inserting row on last rowPosted: Tue Apr 16, 2013 4:22 am Joined: Wed Feb 27, 2013 6:40 am Posts: 6 Inserting a row .... Why not simply Listbox1.InsertRow(Listbox1.LastIndex-1,"") Top Rivo Post subject: Re: inserting row on last rowPosted: Tue Apr 16, 2013 4:55 am Joined: Tue Aug 29, 2006 4:04 am Posts: 506 Location: Indonesia Inserting row does not work. the result should be displayed like 1 apple 10000 2 orange 20000 1 apple 10000 Total < this should printed on last row everytime the button is executed to add new row. thanks Regards, Rivo Top lavalle Post subject: Re: inserting row on last rowPosted: Tue Apr 16, 2013 5:37 am Joined: Wed Feb 27, 2013 6:40 am Posts: 6 Supposed you have a list with 3 columns and 3 rows like Listbox1.ColumnCount = 3 Listbox1.AddRow "1", "Apple","10000" Listbox1.AddRow "2", "Orange","20000" Listbox1.AddRow "#", "Total","30000" In the Action-Event of the AddRow-Button: dim i, x as Integer dim sum As Double x = Listbox1.ListCount // = 3 Listbox1.InsertRow(x-1,"3") x = Listbox1.ListCount // now 4 Listbox1.Cell(x-2,1) = "Banana" Listbox1.Cell(x-2,2) = "15000" for i = 1 to x-1 // sum rows 1,2,3 sum = sum + CDbl(Listbox1.Cell(i-1,2)) next Listbox1.Cell(x-1,2) = Str(sum) // put the sum in the Total-row 4 Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 6 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]
