注册 登录
编程论坛 Delphi论坛

请求帮助,一个关于调用后获取值result的问题!

godrose 发布于 2012-06-22 00:37, 587 次点击
新手报道,关于一个调用后获取值的问题。
function tform1.abc(key: string): string;
var
  str1: string;
begin
      str1:='select * from abc where a=key';
      Result:=str1;
end;

调整用时
abc(str1);//例如key='123';
showmessage(str1);
反馈值str1的时候为什么得不到 需要的‘select * from abc where a=key’
请教高手指点迷经!!!万分感激!!!
1 回复
#2
xindeluoye2012-06-27 10:20
function TForm1.abc(Key: string): string;
begin
  Result := 'Select * from abc Where a= ''' + Key + '''';
end;

调用时应该这样调用:
var
  sTemp: string;
begin
  sTemp := abc('a');
  ShowMessage(sTemp);
end;

结果消息显示为:
'Select * from abc Where a= 'a'
1