我想自定义一个函数,如果两个字符串相同则返回值为true,否则返回值为false。代码如下:
function TForm2.SameNO;
begin
  result:=false;
  with datamodule1.ADOQuery1 do
    begin
      first;
      while not EOF do
      begin
        if Fields.FieldByName('编号').AsString=edit1.Text then
          begin
            result:=true;
            break;
          end;
        next;
      end;
    end;
end;通过adoquery1连接到表,取表中的“编号”字段值逐一与edit1.text比较,如果相等则返回true,问题是不论二者是否相等,返回值总是为true。我是新手,不知道哪个地方存在问题,请大家多多指教!!!!