| Author |
For loop to while loop convet
|
|
| Albert Truter 2004-03-27, 12:21 am |
| Hey all you Delphi Guru's, please help.
I need to convert the following For loop to a nested while loop.
I send programe with as attachment.
Thanks
Albert
alberttruter@webmail.co.za
procedure TfrmLooping.btnloopClick(Sender: TObject);
var
sString : String;
jIndex. iIndex : Integer;
begin
sString := edtStringInitial.Text;
for iIndex := sedStartFirst.Value to sedEndFirst.Value Do
begin
for jIndex := sedStartSecond.Value to sedEndSecond.Value Do
Begin
sString := sString + IntToStr(iIndex) + IntToStr(jIndex);
end;
end;
edtStringOutput.Text := sString;
end;
end.
| |
| Nicolai Hansen 2004-03-27, 12:21 am |
| procedure TfrmLooping.btnloopClick(Sender: TObject);
var
sString : String;
jIndex, iIndex : Integer;
begin
sString := edtStringInitial.Text;
iIndex:=sedStartFirst.Value;
while iIndex<=sedEndFirst.Value do
begin
jIndex:=sedStartSecond.Value;
while jIndex<=sedEndSecond.Value do
Begin
sString := sString + IntToStr(iIndex) + IntToStr(jIndex);
inc(jIndex);
end;
inc(iIndex);
end;
edtStringOutput.Text := sString;
end.
| |
| D. L. von Pontz 2004-03-27, 12:21 am |
| Thanks! Inspiring to me, on how code oughta look!
Nicolai Hansen wrote:
> procedure TfrmLooping.btnloopClick(Sender: TObject);
> var
> sString : String;
> jIndex, iIndex : Integer;
>
> begin
> sString := edtStringInitial.Text;
> iIndex:=sedStartFirst.Value;
> while iIndex<=sedEndFirst.Value do
> begin
> jIndex:=sedStartSecond.Value;
> while jIndex<=sedEndSecond.Value do
> Begin
> sString := sString + IntToStr(iIndex) + IntToStr(jIndex);
> inc(jIndex);
> end;
> inc(iIndex);
> end;
> edtStringOutput.Text := sString;
> end.
|
|
|
|