This page is intended as a supplement to the official documentation on Delphi programming. CodeGear is in the process of putting the Delphi documentation on the Web. Once they have done so, this page will link to the relevant page in the official documentation.
This article is a stub.
Please help enhance the Delphi Programming Wiki by expanding it.
see the VCL Documentation Guidelines for an overview on doc pages



function LeftStr(const AText: AnsiString; const ACount: Integer): AnsiString; overload;
function LeftStr(const AText: WideString; const ACount: Integer): WideString; overload;

The LeftStr function takes 2 parameters. The first parameter is the source string and the second is an integer with number of characters from the beginning of the string.

The result is a substring taken from the beginning of the source string with the length in characters given in the second parameter.

Technical CommentsEdit

(Known issues / Documentation clarifications / Things to be aware of)


  SourceString, SubString: String;
  SubStringLength: Integer;
  SourceString := 'Delphi Wikia'; //string length is 12
  SubStringLength := 6;
  SubString := LeftStr(SourceString, SubStringLength);
  ShowMessage(SubString); //will show 'Delphi'

  SubStringLength := 20; //length is more then the source string
  SubString := RightStr(SourceString, SubStringLength);
  ShowMessage(SubString); //will show the complete SourceString 'Delphi Wikia'

  SubStringLength := -1;
  SubString := RightStr(SourceString, SubStringLength);
  ShowMessage(SubString); //If the SubStringLength is anything lower than 1 then then result will be empty

See AlsoEdit

(Please provide links to items specifically related to this item.)

User Comments/TipsEdit

(Please leave your name with your comment.)

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.