1.TStringList分解字符串
在编程中我们经常需要分解某个字符串,比如“abc,123,334,akl”,把上述字符串根据逗号分解成4个字符串。
procedure TForm1.btnTestClick(Sender: TObject);
var
v_TestList: TStringList;
v_Index: Integer;
begin
v_TestList := TStringList.Create;
try
{采用CommaText}
v_TestList.CommaText := 'abc,123,334,akl';
{采用Delimiter & DelimitedText,可以根据需要调整Delimiter,应用比较灵活
v_TestList.Delimiter := ',';
v_TestList.DelimitedText := 'abc,123,334,akl';}
for v_Index := 0 to v_TestList.Count - 1 do
begin
ShowMessage(v_TestList[v_Index]);
end;
finally
FreeAndNil(v_TestList);
end;
end;

本文分享了关于Delphi编程的一些实用知识点,包括如何使用TStringList分解字符串,解决Delphi6的L594内部错误,调整TListView行高,理解RzCheckBox和CheckBox的OnMouseUp事件差异,以及自定义数据集的方法。此外,还揭示了string类型的数组特性,其索引从1开始。
最低0.47元/天 解锁文章
842

被折叠的 条评论
为什么被折叠?



