TRecCodeInfo=record
    sRecCode:string;       //接收手机号码
    sRecName:string;       //接受手机人
  end;
  PRecCodeInfo=^TRecCodeInfo;
str :string;
 str:=PRecCodeInfo(cmbRecCode.Items.Objects[cmbRecCode.ItemIndex])^.sRecCode;
//cmbRecCode.Items.Objects[cmbRecCode.ItemIndex]这句是什么意思?
//还有这个符号^.又是什么意思,记录的成员应该是这样用呀PRecCodeInfo。sRecCode

解决方案 »

  1.   

    PRecCodeInfo(cmbRecCode.Items.Objects[cmbRecCode.ItemIndex])是一个结构指针.所以要从指针里取值就要用到符号^
      

  2.   

    PRecCodeInfo=^TRecCodeInfo;
    TRecCodeInfo=record
        sRecCode:string;       //接收手机号码
        sRecName:string;       //接受手机人
      end;var
    P:PrecCodeInfo
    begin
        new(P);
        p.sReccode:='aaaa';
        p.sRecName:='ddddd';
    end;
      

  3.   

    //cmbRecCode.Items.Objects[cmbRecCode.ItemIndex]这句是什么意思?property Objects[Index: Integer]: TObject;DescriptionAssociate an object with an existing string by setting the Objects property using the same index as that of the string in the Strings property. Look up the object associated with a string by reading the Objects property with the index of the string. Index gives the position of the string associated with the object, where 0 is the first string, 1 is the second string, and so on. Use the IndexOf method to find the index of the string.Note: The TCustomComboBoxStrings object does not own the objects in the Objects array. Objects added to the Objects array still exist even if the string list is destroyed. They must be explicitly destroyed by the application.//还有这个符号^.又是什么意思,
    指针取值
      

  4.   

    //cmbRecCode.Items.Objects[cmbRecCode.ItemIndex]这句是什么意思?
      我猜想cmbRecCode应该是个列表结构(TList,或TStringList之类的),这个列表可以存放或携带一个对象(object),这句话就是取cmbRecCode当前元素(ItemIndex)的那个对象。    //还有这个符号^.又是什么意思,记录的成员应该是这样用呀PRecCodeInfo.sRecCode
      ^是指针的意思,所谓指针,就是地址。PRecCodeInfo=^TRecCodeInfo,就是声明
      PRecCodeInfo是一个指向TRecCodeInfo结构的指针。 str:=PRecCodeInfo(cmbRecCode.Items.Objects[cmbRecCode.ItemIndex])^.sRecCode;就是取
    cmbRecCode.Items.Objects[cmbRecCode.ItemIndex]这个对象,并把它强制类型转换为TRecCodeInfo类型,然后取出他的sRecCode的肉容(接收手机人),赋给Str变量。  明白了么?
      

  5.   

    cmbRecCode应该是个ComboBox控件;cmbRecCode.ItemIndex是取得cmbRecCode当前所选中的是哪一行;cmbRecCode.Items.Objects[cmbRecCode.ItemIndex]是取得cmbRecCode当前选中的那一行
    所对应的指向手机信息的指针。
    然后用PRecCodeInfo(...)将该指针强制类型转换为RecCodeInfo类型的指针。至于对指针理解,举个简单的例子,
    如果定义:
     aaa: RecCodeInfo;
     bbb: PRecCodeInfo;
    使用时:
    ShowMessage(aaa.sRecCode);
    ShowMessage(bbb^.sRecCode);