我有数组如下: GstrBaudTable    :array[0..19] of string = (
    '50','75','110','134','150','300',
    '600','1200','1800','2400','4800','7200',
    '9600','19200','38400','57600','115200',
    '230400','460800','921600'
  );
有没有一个函数能实现返回如:1200这个字符串所在数组中的位置,即数组的下标值?

解决方案 »

  1.   

    自己写啊
    很简单的
    ------------------------------------------
    procedure TForm1.Button1Click(Sender: TObject);
    const
      GstrBaudTable    :array[0..19] of string = (
        '50','75','110','134','150','300',
        '600','1200','1800','2400','4800','7200',
        '9600','19200','38400','57600','115200',
        '230400','460800','921600'
      );
    var
       i:integer;begin
       for i := 0 to 19 do
       begin
         if  GstrBaudTable[i] = '1200' then
         showmessage(IntToStr(i));
       end;
    end;
      

  2.   

    写一个查找算法吧
    或者把数组都放到
    TStringlist里面
    StringList.Sorted := True;
    AIndex := STringLisd.IndexOf('1200');