property CommaText: string;
请问用这个方法怎么处理“1,2,3,4”这样的字符串,请给出相应的例子参考一下!谢谢了!
请问用这个方法怎么处理“1,2,3,4”这样的字符串,请给出相应的例子参考一下!谢谢了!
解决方案 »
- 哪位大哥能用Idtcpserver and idtcpclient 写个端口转发=端口映射=数据转发
- Out of memory while expanding memory stream!!! 各位达人,拜托了,偶郁闷的说
- 手机短信的问题,SMS
- 此贴讨论DBGrid,TDataset,TDataSource,UpdateSql 的使用和交互问题。。。。。
- ▲▲▲谁能帮我改一下报表显示程序,很简单的,很急!!!▲▲▲
- 关于日期操作的问题
- 高手请进→如何做一个浮动窗口?
- 怎么样在一个Unit里给另外一个Unit里的变量付值
- 关于Button的问题?
- About TQuery的Master/Detail;
- 得到本机的IP地址
- WebBrowser问什么在多线程中获取不到网页原码?
function PartitionString(StrV,PrtSymbol: string): TStringList;
var
iTemp: integer;
begin
result := TStringList.Create;
iTemp := pos(PrtSymbol,StrV);
while iTemp>0 do begin
if iTemp>1 then result.Append(copy(StrV,1,iTemp-1));
delete(StrV,1,iTemp+length(PrtSymbol)-1);
iTemp := pos(PrtSymbol,StrV);
end;
if Strv<>'' then result.Append(StrV);
end;调用:
var
Str:TStrings;
TStr:String;
begin
TStr:='1,2,3,4';
Str:=PartitionString(TStr,',');
end;
begin
Delimiter := ',';
QuoteChar := '"';
SetDelimitedText(Value);
end;procedure TStrings.SetDelimitedText(const Value: string);
var
P, P1: PChar;
S: string;
begin
BeginUpdate;
try
Clear;
P := PChar(Value);
while P^ in [#1..' '] do
{$IFDEF MSWINDOWS}
P := CharNext(P);
{$ELSE}
Inc(P);
{$ENDIF}
while P^ <> #0 do
begin
if P^ = QuoteChar then
S := AnsiExtractQuotedStr(P, QuoteChar)
else
begin
P1 := P;
while (P^ > ' ') and (P^ <> Delimiter) do
{$IFDEF MSWINDOWS}
P := CharNext(P);
{$ELSE}
Inc(P);
{$ENDIF}
SetString(S, P1, P - P1);
end;
Add(S);
while P^ in [#1..' '] do
{$IFDEF MSWINDOWS}
P := CharNext(P);
{$ELSE}
Inc(P);
{$ENDIF}
if P^ = Delimiter then
begin
P1 := P;
{$IFDEF MSWINDOWS}
if CharNext(P1)^ = #0 then
{$ELSE}
Inc(P1);
if P1^ = #0 then
{$ENDIF}
Add('');
repeat
{$IFDEF MSWINDOWS}
P := CharNext(P);
{$ELSE}
Inc(P);
{$ENDIF}
until not (P^ in [#1..' ']);
end;
end;
finally
EndUpdate;
end;
end;这是VCL源码
类本身提供了这个对象方法
昏
是公布了属性
你自己也可以按照VCL的处理方式写一个