delphi TStringListµÄÓ÷¨
delphi TStringListµÄÓ÷¨
TStringsÊÇÒ»¸ö³éÏóÀ࣬ÔÚʵ¼Ê¿ª·¢ÖУ¬ÊdzýÁË»ù±¾ÀàÐÍÍ⣬ӦÓõÃ×î¶àµÄ¡£
³£¹æµÄÓ÷¨´ó¼Ò¶¼ÖªµÀ£¬ÏÖÔÚÀ´ÌÖÂÛËüµÄһЩ¸ß¼¶µÄÓ÷¨¡£
ÏÈ°ÑÒªÌÖÂ۵ļ¸¸öÊôÐÔÁгöÀ´£º
1¡¢CommaText
2¡¢Delimiter & DelimitedText
3¡¢Names & Values & ValuefromIndex
ÏÈ¿´µÚÒ»¸ö£ºCommaText¡£ÔõôÓÃÄØ£¿ÓôúÂë˵»°£º
const
constr :String = 'aaa,bbb,ccc,ddd';
var
strs :TStrings;
i :Integer;
begin
strs := TStringList.Create;
strs.CommaText := constr;
for i := 0 to Strs.Count-1 do
ShowMessage(Strs[i]);
end;
Ö´ÐÐÁËÕâ¶Î´úÂëºó£¬¿ÉÒÔ¿´µ½ShowMessageÏÔʾ³öÀ´µÄ·Ö±ðÊÇ£ºaaa bbb ccc ddd¡£
Ò²¾ÍÊÇ˵£¬strs.CommaText := constrÕâÒ»¾äµÄ×÷Ó㬾ÍÊÇ°ÑÒ»¸ö×Ö·û´®ÒÔ','Ϊ·Ö¸î·û£¬·Ö¶ÎÌí¼Óµ½TStringsÖС£
ÄÇôÈç¹û²»ÊÇÒÔ','À´·Ö¸î£¬ÓÖ¸ÃÔõô×öÄØ£¿ÏÖÔÚ¿´µÚ¶þ¸öÀý×Ó¡£Ê¹ÓÃDelimiterºÍDelimitedText¡£
const
constr :String = 'aaa\bbb\ccc\ddd';
var
strs :TStrings;
i :Integer;
begin
strs := TStringList.Create;
strs.Delimiter := '\';
strs.DelimitedText := constr;
for i := 0 to Strs.Count-1 do
ShowMessage(Strs[i]);
end;
¿ÉÒÔ¿´µ½£¬ ÏÔʾµÄЧ¹ûºÍµÚÒ»¸öÀý×ÓÊÇһģһÑùµÄ¡£½âÊÍһϣº
DelimiterΪ·Ö¸ô·û£¬Ä¬ÈÏΪ£º','¡£DelimitedText¾ÍÊÇ°´DelimiterΪ·Ö¸ô·ûµÄÒ»¸ö´®£¬µÃµ½¸³Öµºó»Ø°ÑÕâ¸ö×Ö·û´®°´DelimiterµÄ×Ö·ûÌí¼Óµ½TStringsÖС£
˵µ½ÕâÀÓÐÏëÆðÒ»¸öÊôÐÔ£¬QuoteChar¡£ÆäĬÈÏֵΪ£º'"'£¨²»°üÀ¨µ¥ÒýºÅ£©
ÓкÎÓÃÄØ£¿¿´Àý×Ó£º
const
constr :String = '"aaa"\"bbb"\"ccc"\"ddd"';
var
strs :TStrings;
i :Integer;
begin
strs := TStringList.Create;
strs.Delimiter := '\';
strs.DelimitedText := constr;
for i := 0 to Strs.Count-1 do
ShowMessage(Strs[i]);
end;
ÏÔʾ³öÀ´µÄÈÔÈ»ÊÇaaa bbb ccc ddd¡£ÎªÊ²Ã´²»ÊÇ£º"aaa" "bbb" "ccc" "ddd"ÄØ£¿
ÔÙÀ´¿´Ò»¸öÀý×Ó£º
const
constr :String = '|aaa|\|bbb|\|ccc|\|ddd|';
var
strs :TStrings;
i :Integer;
begin
strs := TStringList.Create;
strs.Delimiter := '\';
strs.QuoteChar := '|';
strs.DelimitedText := constr;
for i := 0 to Strs.Count-1 do
ShowMessage(Strs[i]);
end;
ÏÔʾ³öÀ´µÄÓÖÊÇaaa bbb ccc
Ïà¹ØÎĵµ£º
ÔÚÏîÄ¿ÖУ¬ÐèÒª×öÒ»¸öÈÕÆÚµÄÌáÐѹ¦ÄÜ£¬Í¦ÓôÃƵģ¬¶ÔÈÕÆڵļÆËã:
ºÜÐÒÔ˵ÄÊÇÔÚdelphi ÖÐÓÐÏÖÓеļÆË㺯Êý£¬DateUtilsµ¥Ôª£»
·¾¶:*\Delphi7\Source\Rtl\Common Ŀ¼Ï¡£
Ìù³öÒ»²¿·Ö:
function IncYear(const AValue: TDateTime;
const ANumberOfYears: Integer = 1): TDateTime;
// function Inc ......
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;
ÉùÃ÷Ò»¸ö¶þάÊý×éµÄ·½·¨ÊÇÓ ......
Õª
Òª£º±¾ÎÄͨ¹ýʹÓÃDelphiºÍWebServices¼¼Êõ¿ª·¢¶ÌÐÅÓ¦ÓóÌÐòµÄʵÀýÏêϸµÄ½éÉÜÁËÈçºÎÔÚDelphiÖпª·¢»ùÓÚWebServices¼¼Êõ
µÄÓ¦ÓóÌÐò¡£
¡¡¡¡¹Ø¼ü×Ö£ºDelphi£»WebService£»¶ÌÐÅÓ¦ÓóÌÐò¿ª·¢
¡¡¡¡Ò»ÌáÆð»ùÓÚWebServices¼¼ÊõµÄÓ¦ÓóÌÐò¿ª·¢£¬Ò»°ãÈËÊ×ÏÈÏëµ½µÄ¿ª·¢¹¤¾ßÊÇVS.net£¬Æäʵ×÷Ϊ¿ìËÙÓ¦ÓóÌÐò¿ª·¢¹¤¾ß
(RAD)µ ......