Quote Originally Posted by WILL
Hmm... thats interesting. I used TStrings.Create as the constructor. I'll give that a try. Odd... normally you'd use the same class objct to create the object you made. :?
That is werry many possibles used some class what is develop from parent

Code:
  type
    TMyParent = class
    end;
    
   TMyInteger = class(TMyParent)
     Procedure ShowMe;
   end;

   TMyString = class(TMyParent)
     procedure ShowMe;
   end;

   TForm1 = class(TForm)
     MyValue : TMyParent;
     constructor create(Aowner : TComponent);override;
   end;

procedure TMyInteger.ShowMe;
begin
  ShowMessage('Hello Integer');
end;


procedure TMyString.ShowMe;
begin
  ShowMessage('Its string');
end;

constructor TForm1.Create(Aowner : TComponent);
begin
   inherited;
   if ParamStr(1) = 'integer')
      then MyValue := TMyInteger.Create
      else MyValue := TMyString.Create;
end;

procedure TForm1.OnClick;
begin
  MyValue.ShowMe;
end;