帮我,55555555555(20分)

  • 主题发起人 主题发起人 兰铃子
  • 开始时间 开始时间

兰铃子

Unregistered / Unconfirmed
GUEST, unregistred user!
function SaveRecord(k:integer):boolean;<br>var i,j:integer;<br>begin<br>try<br>&nbsp; for i:=0 to k-1 do<br>&nbsp; begin<br>&nbsp; &nbsp; Randomize;<br>&nbsp; &nbsp; j:=random(k);<br>&nbsp; &nbsp; while temparray[j]='' then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; j:=j+1;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; with query do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; SQL.clear;<br>&nbsp; &nbsp; &nbsp; sql.add('insert into temp');<br>&nbsp; &nbsp; &nbsp; sql.add('(select * from 试题表 where id =''+temparray[j]+''')')<br>&nbsp; &nbsp; &nbsp; ExecSQL;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; temparray[j]:<br>end;<br>except<br>&nbsp; result:=false;<br>&nbsp; exit;<br>end;<br>result:=true;<br>end;<br>出错提示是[Error] Unit6.pas(32): Statement expected but 'FUNCTION' found<br>[Error] Unit6.pas(40): Undeclared identifier: 'temparray'<br><br><br>怎么回事啊!帮帮忙哦!<br>
 
在UNIT 单元加FUNCTION
 
temparray肯定是拼错了.<br>第一个错是32行以前的代码写的不对.
 
出错提示是[Error] Unit6.pas(32): Statement expected but 'FUNCTION' found<br>[Error] Unit6.pas(40): Undeclared identifier: 'temparray'<br><br>你要把这个函数的上面的和下面的过程代码也贴出来 还有temparray 你是不是没有声明 ? 
 
应该用select into语句吧,不知道你要做什么<br>还有'写少了<br>sql.add(<br>'(select * from 试题表 where id ='''<br>+temparray[j]<br>+''')'<br>);<br>分开看就可以了<br>
 
&gt; Unit6.pas(32): Statement expected but 'FUNCTION' found<br>这个错误和整个程序有关,看看这个函数前面的代码,是不是忘记了分号之类的<br><br>》[Error] Unit6.pas(40): Undeclared identifier: 'temparray'<br>你在函数内没有定义temparray呀,可能是前一个错误引起的,先解决上一个问题。<br>
 
function SaveRecord(k:integer):boolean;<br>var i,j:integer;<br>begin<br>try<br>&nbsp; for i:=0 to k-1 do<br>&nbsp; begin<br>&nbsp; &nbsp; Randomize;<br>&nbsp; &nbsp; j:=random(k);<br>&nbsp; &nbsp; while temparray[j]='' then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; j:=j+1;<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; with query do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; SQL.clear;<br>&nbsp; &nbsp; &nbsp; sql.add('insert into temp');<br>&nbsp; &nbsp; &nbsp; sql.add('(select * from 试题表 where id =''+temparray[j]+''')')<br>&nbsp; &nbsp; &nbsp; ExecSQL;<br>&nbsp; &nbsp; end;<br>temparray[j]:='';<br>&nbsp; end;<br>except<br>&nbsp; result:=false;<br>&nbsp; exit;<br>end;<br>result:=true;<br>end;<br>
 
我是想在FORM上有一个开始答题的按钮,着就是按钮事件<br>点击后就出现题
 
while temparray[j]='' then 错误!<br>应为<br>&nbsp;while temparray[j]='' do<br>
 
1.function SaveRecord(k:integer):boolean;之前的代码没加end;<br>&nbsp; 在function SaveRecord(k:integer):boolean;上一行加end;<br>2.function SaveRecord(k:integer):boolean;前面没加前辍,<br>&nbsp; 比如function Tfrom1.SaveRecord(k:integer):boolean;
 
应该是这个函数前面的语名没写完,如没加END啊,没有“;”号等!
 
后退
顶部