为什么我无法调用全局变量里的值.
以下程序每次点按扭事件时候总提示出错误;
procedure readdata; //这个已经定义在private上面了
s: TStringList; //这个也定义在了implementation 前面
Current,inum,snum,iround,total:Integer;
下面这个过程也定义在这个也定义在了implementation 后面了
//读取数据库数据写入Tstringlist
procedure TfrmYHXT.readdata;
var
i:Integer;
str:string;
begin
s:=TStringList.Create;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Text:='select id from 客户信息表 where ispec=-1';
ADOQuery1.Open;
snum:=ADOQuery1.RecordCount;
if snum<>0 then
begin
ADOQuery1.First;
for i:=0 to snum-1 do
begin
str:=ADOQuery1.FieldByName('id').AsString;
s.Add(str);
ADOQuery1.Next;
end;
end;
ADOQuery1.Close;
ADOQuery1.Free;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Text:='select id from 客户信息表 where ispec=0';
ADOQuery1.Open;
inum:=ADOQuery1.RecordCount;
if inum<>0 then
begin
ADOQuery1.First;
for i:=0 to snum-1 do
begin
str:=ADOQuery1.FieldByName('id').AsString;
s.Add(str);
ADOQuery1.Next;
end;
end;
total:=snum+inum;
ADOQuery1.Close;
ADOQuery1.Free;
end;
procedure TfrmYHXT.btnStartClick(Sender: TObject);
var
i:Integer;
begin
readdata;
ShowMessage(IntToStr(total));
end;
end.