New topic: 

calculate column and column

<http://forums.realsoftware.com/viewtopic.php?t=47108>

         Page 1 of 1
   [ 2 posts ]                 Previous topic | Next topic          Author  
Message        Rivo          Post subject: calculate column and columnPosted: 
Thu Feb 28, 2013 12:09 am                         
Joined: Tue Aug 29, 2006 4:04 am
Posts: 494
Location: Indonesia                Hi,
I was using this code to calculate value on a listbox columns.

 if L_member.text <>"" then
  Dim o as integer
  dim row as integer
  row =Listbox1.listcount-1
  dim the_word as string
  dim bFound as boolean
  bFound = false
  
  if bfound = false  then
  Listbox1.AddRow  ""
  Listbox1.cell(Listbox1.LastIndex,0) =  
data_product.cell(data_product.ListIndex,0)
  Listbox1.cell(Listbox1.LastIndex,1) =  
data_product.cell(data_product.ListIndex,1)
  Listbox1.cell(Listbox1.LastIndex,2) =  
data_product.cell(data_product.ListIndex,2)
  Listbox1.cell(Listbox1.LastIndex,3) =  EditField2.text
  Listbox1.cell(Listbox1.LastIndex,4) =  
data_product.cell(data_product.ListIndex,7)
  dim z as double
  z=CDbl(listbox1.cell(o,4))* CDbl(window1.listbox1.cell(o,3))
  Listbox1.cell(o,6) =  Format(z , "###,##0")
  
  Dim o as integer
  dim a,b as Double
  dim c,d as Double
  a=CDbl(ListBox1.Cell(Listbox1.LastIndex, 6 ))
  b=10
  c=(a*b)/100*-1
  ListBox1.AddRow  ""
  listBox1.cell(listBox1.lastindex,2)="Disc 10%"
  listBox1.cell(listBox1.lastindex,5)=format(c,"-###,##0")
  end if
end if


I want to add new row as a discount for every item I have added. 
This is only work for the first item, and showing zero on the next items.
I'm sure, the problem is I have to calculate the row -1. but I dont know how to 
do it.

any help.?


thanks

regards,
Rivo   
                             Top                neonash7777          Post 
subject: Re: calculate column and columnPosted: Thu Feb 28, 2013 11:19 am       
                          
Joined: Mon Nov 29, 2010 7:01 pm
Posts: 408                I'm still trying to decipher what you're doing, but 
to start you could try cleaning up your code.

For example:
dim row as integer
row =Listbox1.listcount-1

Can simply be 
dim row as integer = Listbox1.listcount-1


And why are you doing this:
dim bFound as boolean
bFound = false

if bfound = false  then


None of that code amounts to anything.
When you instantiate a boolean it is already false so you don't need to assign 
it false. Secondly you don't need the if statement at all because it will 
always execute with your current code - it's pointless.


If you want to add a discount row for every row that exists you need to do 
something like this

Dim rowCount as integer = Listbox1.listcount-1
For i as integer = 0 to rowCount
  Listbox1.AddRow  ""
  Listbox1.cell(Listbox1.LastIndex,0) = listbox1.cell(i,0)
  ...
Next
   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 2 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]

Reply via email to