help with for loop

Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2005
Posts: 4
Reputation: delgado is an unknown quantity at this point 
Solved Threads: 0
delgado delgado is offline Offline
Newbie Poster

help with for loop

 
0
  #1
Jun 28th, 2005
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...
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 6
Reputation: Shulc is an unknown quantity at this point 
Solved Threads: 0
Shulc's Avatar
Shulc Shulc is offline Offline
Newbie Poster

Re: help with for loop

 
0
  #2
Jul 6th, 2005
basicly you want to add numbers? didnt get quite your post
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 4
Reputation: delgado is an unknown quantity at this point 
Solved Threads: 0
delgado delgado is offline Offline
Newbie Poster

Re: help with for loop

 
0
  #3
Jul 10th, 2005
basically thats it....i want to add all the numbers from the price column.....want the sum of all the numbers..
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 6
Reputation: Shulc is an unknown quantity at this point 
Solved Threads: 0
Shulc's Avatar
Shulc Shulc is offline Offline
Newbie Poster

Re: help with for loop

 
0
  #4
Jul 11th, 2005
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[i];
end;
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 4
Reputation: delgado is an unknown quantity at this point 
Solved Threads: 0
delgado delgado is offline Offline
Newbie Poster

Re: help with for loop

 
0
  #5
Jul 11th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 41
Reputation: mrmike is an unknown quantity at this point 
Solved Threads: 0
mrmike mrmike is offline Offline
Light Poster

Re: help with for loop

 
0
  #6
Jul 12th, 2005
the easiest way of adding into array and increasing at same time is as follows

Pascal and Delphi Syntax (Toggle Plain Text)
  1. var
  2. myarray :array of integer;
  3. lastrecord: integer;
  4.  
  5. begin
  6. lastrecord:=0;
  7.  
  8. while lastrecord<20 do
  9. begin
  10. setlength(myarray,lastrecord+1);
  11. myarray[lastrecord]:=input_value;
  12. lastrecord:=lastrecord+1;
  13. end;
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 4
Reputation: delgado is an unknown quantity at this point 
Solved Threads: 0
delgado delgado is offline Offline
Newbie Poster

Re: help with for loop

 
0
  #7
Jul 16th, 2005
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Pascal and Delphi Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC