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...

Recommended Answers

All 6 Replies

basicly you want to add numbers? didnt get quite your post :?:

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

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;

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.

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;

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.