about TstringList (5分)

  • 主题发起人 主题发起人 kouchun
  • 开始时间 开始时间
K

kouchun

Unregistered / Unconfirmed
GUEST, unregistred user!
var s:TstringList
begin
s:=TstringList.creat;
s.add('abc');
s.add('123');
edit1.text:=s.values['123'];<------what is this mean??
s.free;
 
在你这个程序里,你这个意思什么也不是,本来他的意思是:取得Name为123的项的值,但是添加方式
应该为s.Add('123='Value'),这样,你使用 Edit1.Text := s.Values['123'];才有意义
否则Edit1.text为空
 
我看是这样写吧
var s:TstringList;
i:integer;
begin
s:=TstringList.Create;
s.add('abc');
s.add('123');
s.Sort;
if s.Find('123', i) then
edit1.text:=s.Strings;
s.free;
end;
-----------------
Represents the value part of a string associated with a given Name,
on strings with the form Name=Value.

property Values[const Name: string]: string;

Description

When the list of strings for the TStrings object includes strings of the form Name=Value,
use Values to get or set the value part of a string associated with
a specific name part. If the list does not contain any strings of the proper Name=Value form,
or if none of those strings matches the Name index,
Values returns an empty string.

Note:
The Name index is case-insensitive.
That is, Values is the value part for the first occurrence of Name
or an equivalent string that differs only in case.

The Name that identifies the string is to the left of the
equal sign (=), and the current Value of the Name identifier is on the right side.
There should be no spaces present before or after the equal sign.
 
thanks all!
 
后退
顶部