Delphi Tutorial 1
Results 1 to 2 of 2

Thread: Delphi Tutorial 1

  1. #1
    Member
    Join Date
    Feb 2002
    Posts
    84

    Post Delphi Tutorial 1

    Delphi programming tutorial 1

    I've seen a lot of tutorials about QBasic, VB and C# and I think maybe It's time for a little Delphi
    tutorial. Delphi is a RAD tool which stands for Rapid Application Development it means that you can
    write a large program in less time. You can use Delphi to develop all kinds of applications, I'm
    currently working on a 3D game engine TeqSoft , but Delphi also provides a large variety of network tools which
    are very easy to use. For this tutorial I used Delphi 5 but it should be compatible with other versions.
    Well let's just start.

    When you start Delphi there's already a application template loaded, if not then choose File -> New
    Application and voila there it is.

    Go to the component palette and select Label, now go to the main form (which should be Form1) and click
    on this form, the label should now appear on the form itself with the caption Label1. Now go back to
    the component palette and select a Button, repeat the same procedure as used with the label and now
    you have a label and a button on your main form. Now doubleclick on the Button and you will be sent to
    the source code screen, and you will probably see this.

    Code:
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    
    end;
    Now add the following code -> Label1.Caption:='Hello World!'; so the code will look like this:

    Code:
    procedure TForm1.Button1Click(Sender: TObject);
    begin
     Label1.Caption:='Hello World!';
    end;
    So far so good, now run the program with the green arrow or type F9, you will see that your program
    starts and if you click the button, the text from label1 changes into Hello World!. This was already
    your first delphi program.

    The next program we are going to make is a simple calculator so after this you also know a little bit
    how to work with numbers under Delphi.

    First start with a new application, go to the component palette, select an Edit(box), place it on
    the form and repeat this until you have three edits on your form. Also put a button on the form.

    Now there's a little problem the Delphi editboxes can only handle strings and not numbers, but Delphi
    has a little trick to solve this and transform the different types of data.

    Change a string into a number -> StrToInt
    Change a number into a string -> IntToStr

    Go back to the source code and add the following code to the ButtonClick procedure, so the code will
    look like this:

    Code:
    procedure TForm1.Button1Click(Sender: TObject);
    begin
     Edit3.Text:=IntToStr(StrToInt(Edit1.Text) + StrToInt(Edit2.Text));
    end;
    Now what this piece of code actually does is this, it transforms the text from Edit1 and Edit2 into
    a number and transforms the sum of these two numbers back into a string and places it into Edit3.
    You can check this by running your program and fill in Edit1 and Edit2 with a number, when you click
    the button Edit3 will return the result.

    So far so good, this was a beginner tutorial I wrote, if you want more tutorials about delphi reply
    and I will provide you with some more information.
    [shadow]OpenGL rules the game[/shadow]http://www.AntiOnline.com/sig.php?imageid=499

  2. #2
    Senior Member
    Join Date
    Nov 2001
    Posts
    4,786
    more...more!
    Bukhari:V3B48N826 “The Prophet said, ‘Isn’t the witness of a woman equal to half of that of a man?’ The women said, ‘Yes.’ He said, ‘This is because of the deficiency of a woman’s mind.’”

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •