|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
New to Programming
Hey guys and gals,
I'm pretty new to programming (and here actully, first post), I've began programming Delphi as my first real language as it is my college course chosen language (sucks). Anyway, heres my noobish question. Is there a way to add items in a ListBox together... so in my list box i've got these peices of data: 1 2 3 4 5 Is there a way to add them all, so 1+2+3+4+5? Any help is apreciated, thanks again. Matt. |
|
#2
|
|||
|
|||
|
Code:
function TForm1.ListTotal: Integer;
var
i: integer;
begin
Result := 0;
for i := 0 to Listbox.Count-1 do begin
Result := Result + strToInt(Listbox.Items[i]);
end;
end;
Of course, in the real world you would want to do some checks to make sure the items in the listbox were actually integers. Clive |
|
#3
|
|||
|
|||
|
Thanks alot for the help, for our project its not needed to check if they were integers, instead only VALID data could be entered, so the check hasnt been implemented as of yet.
Thanks for the help, its been really helpful, i'll be sure to add devshed to the credits of the project. I'm sure you will see me asking for help again sometime soon. Thanks again Clive. Matt. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Delphi Programming > New to Programming |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|