954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Basic knowledge

Hi people ,

I have an easy question(but lack the knowledge in Delphi),

I have a piece of code that i want to run but don't want to type it over for every time
it has to be run (not very good coding then). Is there a way i can place it in a procedure
or function and just call it every time(like a method).

An Example would be clearing a bunch of TEdit boxes at different button events or Naming Labels based on Grid columns?


#Note I'm working with Delphi 6

ReaperUser101
Newbie Poster
15 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

Just put it in a function/procedure and call it. Define it like this:

interface

TForm1 = class(TForm)
private
  procedure RepetitiveTask;
end;

implementation

procedure TForm1.RepetitiveTask;
begin
  // ...
end;
pritaeas
Posting Expert
Moderator
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 874
 

Thanks pritaeas!
I managed to do it on my own , but in the same why you explain it here.
All I did different is add components.

procedure ClearEdits (a,b: TEdit);
begin
 a.Clear;
 b.Clear;
end;
ReaperUser101
Newbie Poster
15 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You