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


Delphi

Avatar of undefined
Last Comment
TName

8/22/2022 - Mon
TName

ShowMessage(Format('The Name of the User is %s %s', ['Application','Maker']));
TName

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
TName

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Applicationmaker

ASKER
This was what i needed!
Thanks!
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
TName

You're welcome!