Page 1 of 1

Delphi Exercises (While Loop)

Posted: Sat Mar 17, 2007 5:03 am
by RomeoMabasa
Hi,

I need help with the following Delphi exercise.

1. Create a form and choose numbers randomly. The loop stops when the number 10 is chosen. (Use Randomize once Before the Loop).

Posted: Sat Mar 17, 2007 6:42 am
by volka
What do you got so far?
Sounds very much like school work.

Re:Delphi Exercises (While Loop)

Posted: Sat Mar 17, 2007 9:12 am
by RomeoMabasa
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


It's one of the exercises I'm working on.

I have:

[syntax="delphi"]var inum:integer

Begin

inum:=IntToStr(EdtCapture.text);

while inum <> 10 do
RedDisplay.Lines.Add(StrToInt(inum)); // To Display the number that the user has selected
//Don't know how to make sure that the loop doesn't go endlessly.
end;
-------------------

If I try the If Statement it works:

Here's the code:

Code: Select all

If inum <> 10 then
    RedDisplay.Lines.Add(StrToInt(inum))
Else
    LblMessage.Caption:='The number 10 has been captured';
end; //If

feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]