0

this may seem basic but i'm a beginner...i'm writing a program and i need to calculate costs of items which i store into a table and an array.....is there any property or preocedure i could call to enable me to read and add consecutively a set of real numbers in one column in a table....

e.g
item_number//////////////price


1 8.99
2 2.69
3 5.52

i want to beable to add all the prices on a button click to get a total value....
any help no matter how little would be aprreciated...

3
Contributors
6
Replies
8
Views
12 Years
Discussion Span
Last Post by delgado
0

basically thats it....i want to add all the numbers from the price column.....want the sum of all the numbers..

0

you have a known array of numbers/items?


in pseudo code:

on click event

sum := 0
for i := 1 to length_of_array do
begin
sum := sum + array;
end;

0

well the array is not of a known size.....it depends on how many numbers the person has entered....thanks for the pseudo code.....thats part of it but how do i get each number the person has entered to be stored into the array.

0

the easiest way of adding into array and increasing at same time is as follows

var
 myarray :array of integer;
 lastrecord: integer;

begin
 lastrecord:=0;

while lastrecord<20 do
 begin
  setlength(myarray,lastrecord+1);
  myarray[lastrecord]:=input_value;
  lastrecord:=lastrecord+1;
 end;
0

thanks 4 da help...can't try it out now...had to format my pc...thanks 4 da hepl as soon as i try it out i'll let u know if it works the way i wanted...thanks.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.