User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 397,752 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,548 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser:
Views: 2732 | Replies: 6
Reply
Join Date: Jun 2005
Posts: 4
Reputation: delgado is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
delgado delgado is offline Offline
Newbie Poster

Help help with for loop

  #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...
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2005
Posts: 6
Reputation: Shulc is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Shulc's Avatar
Shulc Shulc is offline Offline
Newbie Poster

Re: help with for loop

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

Re: help with for loop

  #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  
Join Date: Jul 2005
Posts: 6
Reputation: Shulc is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Shulc's Avatar
Shulc Shulc is offline Offline
Newbie Poster

Re: help with for loop

  #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  
Join Date: Jun 2005
Posts: 4
Reputation: delgado is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
delgado delgado is offline Offline
Newbie Poster

Re: help with for loop

  #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  
Join Date: May 2005
Posts: 41
Reputation: mrmike is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
mrmike mrmike is offline Offline
Light Poster

Re: help with for loop

  #6  
Jul 12th, 2005
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;
Reply With Quote  
Join Date: Jun 2005
Posts: 4
Reputation: delgado is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
delgado delgado is offline Offline
Newbie Poster

Re: help with for loop

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Pascal and Delphi Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Pascal and Delphi Forum

All times are GMT -4. The time now is 3:27 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC