Fungsi Left, Mid, Right String Di Delphi

.LeftStr() takes a certain portion of the left side of a string.
. MidStr() takes a specified number of characters from a string.
. RightStr() takes a certain portion of the right side of a string.

Let’s say we have a string Dstr := ‘Delphi is the BEST’, then LeftStr(Dstr, 5) := ‘Delph’
MidStr(Dstr, 6, 7) := ‘i is th’

 

 

RightStr(Dstr, 6) := ‘e BEST’
~~~~~~~~~~~~~~~~~~~~~~~~~
function RightStr
(Const Str: String; Size: Word): String;
begin
if Size > Length(Str) then Size := Length(Str) ;
RightStr := Copy(Str, Length(Str)-Size+1, Size)
end;

function MidStr
(Const Str: String; From, Size: Word): String;
begin
MidStr := Copy(Str, From, Size)
end;

function LeftStr
(Const Str: String; Size: Word): String;
begin
LeftStr := Copy(Str, 1, Size)
end;
~~~~~~~~~~~~~~~~~~~~~~~~~

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s