Hola mjjj.
Se me ocurrió otra opción usando cuatro
TEdit (para el ejemplo: Edit1, Edit2, Edit3 y Edit4).
Código Delphi
[-]
...
implementation
function MakeIP(Oct: array of string): string;
var
i: Integer;
begin
for i:= Low(Oct) to High(Oct) do
Result := Result + Oct[i] + '.';
SetLength(Result, Length(Result)-1);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
Ed: TEdit;
begin
for i:= 1 to 4 do
begin
Ed := TEdit(FindComponent('Edit'+IntToStr(i)));
Ed.MaxLength := 3;
SetWindowLong(Ed.Handle, GWL_STYLE,
GetWindowLong(Ed.Handle, GWL_STYLE) + ES_NUMBER);
end;
end;
procedure TForm1.EditExit(Sender: TObject);
begin
if not (StrToInt(TEdit(Sender).Text) in [0..255]) then
begin
TEdit(Sender).SetFocus;
raise Exception.Create('Valor fuera de rango');
end;
end;
...
Llamada de ejemplo:
Código Delphi
[-]
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(MakeIP([Edit1.Text, Edit2.Text, Edit3.Text, Edit4.Text]));
end;
Saludos.
