zfc:='1,3,45,72,89...' 不确定的个数我想通过动态数组得到
for i:=0 to 动态数组的下标 do
begin
   showmessage(arraysz[i]);
end;
结果是
  显示
  1
  3
  45
  72
  89
  。
  。
  。
  。
  。
  。
  。
  。

解决方案 »

  1.   

    在vb中是这样用的
    Private Sub Command1_Click()
      Dim sz
      //split返回一个下标从零开始的一维数组
      sz = Split(Text1.Text, ",") 
      For i = 0 To UBound(sz)  //UBound数组下标
        MsgBox sz(i)
      Next i
    End Sub
      

  2.   

    var
      str, strtemp: string;
      strarray: array of string;
      i, j, k: integer;
    begin
      strtemp := '';
      str := '1,234,2342,5324,2324';
      setlength(strarray, length(str));
      k := 0;
      for i := 1 to length(str) do
      begin
        if (str[i] <> ',') and (i <> length(str)) then
        begin
          strtemp := strtemp + str[i];
        end
        else
        begin
          if i = length(str) then
          begin
            strtemp := strtemp + str[i];
          end;
          strarray[k] := strtemp;
          strtemp := '';
          k := k + 1;
        end;
      end;
      for j := 0 to k - 1 do
      begin
        showmessage(strarray[j]);
      end;
    可以得到你需要的结果
      

  3.   

    for i:=0 to high(动态数组)-1 do
    begin
       showmessage(arraysz[i]);
    end;
      

  4.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
    zfc : string;
    i : integer;
    split_zfc : Tstringlist;
    arraysz : array of string;
    begin
    split_zfc := TStringList.Create;
    try
    zfc:='1,3,45,72,89,12,44';
    i := pos(',',zfc);
      while i <> 0 do
      begin
          split_zfc.Add(copy(zfc,1,i-1));
          delete(zfc,1,i);
          i := pos(',',zfc);
      end;
    split_zfc.Add(zfc); setlength(arraysz,split_zfc.Count);
    for i := 0 to split_zfc.Count - 1 do
     begin
       arraysz[i] := split_zfc.strings[i];
     end; for i:=0 to high(arraysz) do
    begin
       showmessage(arraysz[i]);
    end;
    finally
    split_zfc.Free;
    end;
    end;
      

  5.   

    for v_iCount := Low(数组名) to High(数组名) do
    begin
       showmessage(数组名[i]);
    end;
      

  6.   

    我认为用TStringList来处理比较好
    var
      sl: TStringList;
      zfc: String;
      arraysz: array of String;
      iLoop: Integer;
    begin
      zfc := '1,3,45,72,89...'; //不确定的个数
      sl := TStringList.Creat;
      sl.CommaText := zfc;      //利用TStringList分割字符串,因为TStringList是用","进行分割字符串的
      SetLength(arraysz, sl.Count);
      for iLoop := 0 to sl.Count - 1 do
        arraysz[iLoop] := sl.String[iLoop];  //给字符串数组赋值
      sl.Free;
    end;