我自己生明了一个Tstrings类型
e:TStrings;
但我用text对其进行赋值,会出现运行时错误
e.text:='xxx';//运行时错误
用同样的memo控件里的lines(也是tstrings)对其进行整体赋值便没错
e:=memo.lines;
showmessage(e.text);
我以为是没有为e分配内存空间导致出错,还请各位指教

解决方案 »

  1.   

    e := TStringList.Create;
    e.text:='xxx';//
      

  2.   

    e:=TStringList.Create;
    e.Text := 'xxx';
      

  3.   

    e.create也会产生运行时错误
    e := TStringList.Create;可以为其分配空间!,谢谢了。但我不知道,我声明的是TStrings啊,为什么要用TStringList.Create;呢?是不是TStrings继承自TStringList啊,能清楚的说一下吗(我先用的TStrings.create也产生运行时错误)
      

  4.   

    TStrings是一个抽象类吧,不能直接create,要用继承它的TStringList,而且,用StringList.Add(),StringList.Strings[i]来引用