delphi 处理字符串 分割
procedure TfrmPutin.BitBtn1Click(Sender: TObject);
var
fini: Tinifile;
s: string;
MyStr, SubStr: string;
myStringList: TStringList;
i: Integer;
Result: Boolean;
OutPutList: TStringList;
constr, str, str1, str2, str3, str4: string;
strs: TStrings;
begin
OutPutList := TStringList.Create;
Result := false;
try
if strtoint(edthour.Text) < 24 then
begin
MessageBoxEx(LanI.GT(input24hInteger));
edthour.SetFocus;
end;
except
MessageBoxEx(LanI.GT(input24hInteger));
edthour.SetFocus;
end;
fini := tinifile.Create(ExtractFilePath(ParamStr(0)) + lood.ini);
s := fini.ReadString(TYPECODE, LABEL, XCR);
if Length(edtSpid.Text) > 0 then
begin
writeWorkLog(edtSpid.Text);
writeWorkLog(s);
SubStr := edtSpid.Text;
MyStr := s;
constr := s;
strs := TStringList.Create;
strs.Delimiter := ,;
strs.DelimitedText := constr;
for i := 0 to strs.Count - 1 do
begin
if Pos(SubStr, strs[i]) > 0 then
begin
Result := True;
Exit;
end;
end;
if Result then
chkspid
else
MessageBoxEx(LanI.GT(pleaseBottles));
exit;
end;
end;
strs := TStringList.Create; strs.Delimiter := ‘,’; strs.DelimitedText := constr; for i := 0 to strs.Count - 1 do 这一块是处理字符串的 打印就是数组了
procedure TForm1.btn1Click(Sender: TObject); var
constr,str,str1,str2,str3,str4:string; strs :TStrings; i:Integer; begin constr:=‘1-2-3’; strs := TStringList.Create; strs.Delimiter := ‘-’; strs.DelimitedText := constr; for i := 0 to Strs.Count-1 do ShowMessage(Strs[i]); end;
end.
