请教一语法问题,  property aaa: String index 0 read Getaaa write Setaaa;
                property bbb: String index 1 read Getaaa write Setaaa;
                property ccc: String index 2 read Getaaa write Setaaa;这里的 index x 是何意?谢谢!

解决方案 »

  1.   

    type
      TForm1 = class(TForm)
        procedure FormCreate(Sender: TObject);
      private
        FStrDate: string;
        function Getaaa(const Index: Integer): String;
        procedure Setaaa(const Index: Integer; const Value: String);
      public
        property aaa: String index 0 read Getaaa write Setaaa;
        property bbb: String index 1 read Getaaa write Setaaa;
        property ccc: String index 2 read Getaaa write Setaaa;
      end;var
      Form1: TForm1;implementation{$R *.dfm}{ TForm1 }function TForm1.Getaaa(const Index: Integer): String;
    begin
      case Index of
        0: Result := Copy(FStrDate, 1, 4);
        1: Result := Copy(FStrDate, 6, 2);
        2: Result := Copy(FStrDate, 9, 2);
      end;
    end;procedure TForm1.Setaaa(const Index: Integer; const Value: String);
    begin
      case Index of
        0:;//略
        1:;
        2:;
      end;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      FStrDate := '2006-01-02';
      ShowMessage(aaa);
      ShowMessage(bbb);
      ShowMessage(ccc);
    end;