In definition of your procedure, write your form class name + dot.
For example if your form's class is TForm1
write it this way:
procedure TForm1.SendTextToSocket(Socket: TCustomWinSocket; S: AnsiString);
However, in declaration under public, you should do it the way you've done.
Now, calling this method from another class is easy. Just add its unit to the uses section of the user unit. Then, call it like this: Form1.SendTextToSocket
Here's an example:
Main Form Unit
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
procedure MyMethod(Param1:Integer);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.MyMethod(Param1:Integer);
begin
//do something
end;
end.
Second Form Unit
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm2 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm2.FormCreate(Sender: TObject);
begin
Form1.MyMethod(5);
end;
end.