Delphi ×Ö·û´®²Ù×÷
³£Íü¼Ç£¬ÔÚ´Ë×ö±Ê¼Ç¡£
Õ⼸¸öº¯Êý¶¼°üº¬ÔÚStrUtilsÖУ¬ËùÒÔÐèÒªuses StrUtils;
¼ÙÉè×Ö·û´®ÊÇ Dstr := ’Delphi is the BEST’, ÄÇô
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;
Õ⼸¸öº¯Êý¾³£½áºÏPos, Length, CopyʹÓÃ
²ð·Ö×Ö·û´®µÄº¯Êý [2005-12-13]
delphiÖÐûÓÐÌṩ´ËÀຯÊý£¬´Ó´ó¸»ÎÌÕÒÁËÒ»¸ö
function split(src,dec : string):TStringList;
var
i : integer;
str : string;
begin
result := TStringList.Create;
repeat
i := pos(dec,src);
str := copy(src,1,i-1);
if (str='') and (i>0) then
begin
delete(src,1,length(dec));
continue;
end;
if i
Ïà¹ØÎĵµ£º
procedure mc_SplitStr(sourStr:String;splitChar:String;desLst:TStringList);
var
tmpStr:String;
sValue:String;
iStart,iPos:Integer;
begin
try
desLst.Clear; //ºÜÖØÒª£¬·ñÔò£¬»áÒ» ......
VCLÖеÄShapeÊǸöºÜ²»´íµÄ¿Ø¼þ£¬¿ÉÒÔÑ¡Ôñ¼¸ÖÖͼÐΣ¬ÒÔÂú×ãÎÒÃǵÄÐèÇ󣬵«ÓÐʱºò¾ÍÊǾõµÃËüµÄ¿ÉѡͼÐÎÉÙÁËÒ»µã£¬±ÈÈçÎÒÃÇÏëÒªÒ»¸öÈý½ÇÐΣ¬ËüȴûÓС£ÓÚÊǾÍÏëµ½À´À©Õ¹Ò»ÏÂÕâ¸ö¿Ø¼þ£¬ÃûΪShapeEx¡£ÆäʵÀ©Õ¹µÄ¹¦Äܲ»¶à£¬Ö»ÊÇÔö¼ÓÁËһЩͼÐΡ£¶øÀàÒ²²¢²»ÊǼ̳Ð×ÔTShape£¬¶øÊǼ̳Ð×ÔTGraphicControl£¬ÕâÑù¿ÉÒÔÈÃÎÒÃdz¹µ×¿´¿´Í¼ÐÎ ......
ÕâÊÇÒ»¸öʵÀý£º
procedure TMainForm.Button1Click(Sender: TObject);
var
arr:array of array of string;
begin
setlength(arr,2,3);
arr[1,2]:='this is a test';
setlength(arr,0,0);
setlength(arr,4,5);
showmessage(arr[1,2]);
end;
ÉùÃ÷Ò»¸ö¶þάÊý×éµÄ·½·¨ÊÇÓ ......
×î½ü¿ª·¢³ÌÐòÐèҪʹÓÃTList¹¦ÄÜ£¬×ªÔØ´ËÎÄÕ£¬ÒÔ×÷²Î¿¼¡£
¿´ÁËÕâÀï±êÌ⣬´ó¼Ò¿ÉÄÜÒÔΪÎÒ»á̸TListBox¿Ø¼þ£¬ÄǾʹíÁË¡£ÎÒҪ̸µÄÊÇDelphiÌṩ¸øÎÒÃǵľßÓÐÁбíÐÔÖʵÄÀࣺTstringList¡¢TListºÍTObjectList¡£TstringListÓÃÀ´´æ·Å×Ö·û´®£¬TList´æ·ÅÖ¸Õ룬¶øTObjectListÔò´æ·Å¶ÔÏó(Object)¡£
ÔÚÎÒÃÇʹÓÃDelphi µÄ¹ý³ÌÖУ¬Óкܶà ......
TCollection ÊÇTCollectionItenm¶ÔÏóµÄÒ»¸öÈÝÆ÷¡£
Àà¹ØÏµTObject→TPersistent
¡¡¡¡Ã¿Ò»¸öTCollection¶¼ÓµÓÐÒ»×éTCollectionItem¶ÔÏó¡£
¡¡¡¡ÔÚÆäItemsÊôÐÔÊý×éÖУ¬TCcllection±£´æ¼¯ºÏÏîÄ¿µÄÒ»¸öϱꡣCount ÊôÐÔ°üº¬Á˼¯ºÏµÄÏîÄ¿ÊýÁ¿¡£Ê¹ÓÃAddºÍClear·½·¨¿ÉÒÔÏò¼¯ºÏÖмÓÈëÏîÄ¿ºÍ´Ó¼¯ºÏÖÐɾ³ýÏîÄ¿¡£
¡¡¡¡´ÓTCollect ......