Link to home
Start Free TrialLog in
Avatar of Applicationmaker
Applicationmaker

asked on

Formating a String

I want to Format a String with other String variables..

Like
MyString:='The Name of the User is %s %s';
MyString:=FormatString(MyString,UserFirstName,UserLastName);
ShowMessage(MyString);

I already programmed this by myself, but i want to know if there is a function or procedure which does this...
I knowed the C++ Formating procedure printf.
but i want to have it for Delphi.

Thanks for help


Avatar of TName
TName

ShowMessage(Format('The Name of the User is %s %s', ['Application','Maker']));
Or, if you prefer:

procedure TForm1.Button1Click(Sender: TObject);
var
  MyString, userFirstName, userLastName:String;
begin
  userFirstName:='Application';
  userLastName:='Maker';
  MyString:=Format('The Name of the User is %s %s', [userFirstName,userLastName]);
  ShowMessage(MyString);
end;

Regards.
ASKER CERTIFIED SOLUTION
Avatar of TName
TName

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Applicationmaker

ASKER

This was what i needed!
Thanks!
You're welcome!