with table1 do
begin
setkey;
fieldbyname('name').AsString:=edit1.Text;
if gotokey then
statusbar1.SimpleText:='找到了关于'+edit1.text+'的记录'
else
messagedlg('呵呵,没有找到这个国家!',mtwarning,[mbok],0);
end;请教: 1.setkey 的用法?
2.还有第四行的fieldbyname('name').AsString 是什么意思?
3.还有gotokey的用法?
向大家请教,我刚开始学,请原谅我的无知!!
begin
setkey;
fieldbyname('name').AsString:=edit1.Text;
if gotokey then
statusbar1.SimpleText:='找到了关于'+edit1.text+'的记录'
else
messagedlg('呵呵,没有找到这个国家!',mtwarning,[mbok],0);
end;请教: 1.setkey 的用法?
2.还有第四行的fieldbyname('name').AsString 是什么意思?
3.还有gotokey的用法?
向大家请教,我刚开始学,请原谅我的无知!!
你上面的语句的意思是查找字段name内容为edit1.text的记录
gotokey是以SETKEY后的fieldbyname设置内容作为查找条件,返回记录,
Use GotoKey to move to a record specified by key values assigned with previous calls to SetKey or EditKey and actual search values indicated in the Fields property.If GotoKey finds a matching record, it positions the cursor on the record and returns true. Otherwise the current cursor position remains unchanged, and GotoKey returns false.
上面的意思就是说GOTOKEY查找符合的条件后,如果有记录就返回true,并指向记录,如果没有就返回FALSE
2,filedbyname("name").asstring是设置需要查找的字段以及符合条件的内容
3,gotokey就相当于执行查找条件了,返回是否存在符合条件的记录,返回值是一个boolean型的,如有的话,并指向记录集
2,将字段值转换为字符型,即string;
3,不太清楚,不敢胡说!不过你可以F1