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

Recommended Answers

All 2 Replies

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;

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;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.