Delphi Exercises (While Loop)

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
RomeoMabasa
Forum Newbie
Posts: 4
Joined: Sat Mar 17, 2007 4:56 am

Delphi Exercises (While Loop)

Post 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).
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

What do you got so far?
Sounds very much like school work.
RomeoMabasa
Forum Newbie
Posts: 4
Joined: Sat Mar 17, 2007 4:56 am

Re:Delphi Exercises (While Loop)

Post 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]
Post Reply