for this Delphi Tutorial project, i will use 3 methods :
1. Using Edit Text and Button
I assume we already open Delphi application and we see a form for us to build the project.
First Step , add Edit Text and Button component. You can find Edit Text and Button Component at component tool bar. Here is the picture :
To add the component, simply click the component, and then click again on the Form. Set the position of the component. You can set the component like this or you can set it with your own :
After we set the component position, now we add command on Button component. This command will make Edit Text component write 'Hello World' when we click the button component.
To add that command on Button component, click Button component, and then at Object Inspector (usually it place at bottom left Delphi application). Click on 'Event' tab, and double click OnClick.
After we click Event OnClick, now we put our command here :
the command should write like this :
procedure TForm1.FormClick(Sender: TObject);
begin
Edit1.Text := 'Hello World!'
end;
Now, run our Project.
Click the Button, and see the result..
2. Using Button and ShowMessage command.
Add Button component to Form. And then, on Button OnClick Event, add this command :
2. Using Button and ShowMessage command.
Add Button component to Form. And then, on Button OnClick Event, add this command :
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage('Hello World!');
end;
now Run the project, click the Button, and see the result..
3. Using Button and Label Component.
Now try to add Button and Label Component to the Form.
set position for Button and Label on Form.
Now, on Button OnClick event, write the code like this :
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption := 'Hello World!';
end;
Run the project, and try to click the Button. See the result..