Ver Mensaje Individual
  #16  
Antiguo 05-09-2008
Avatar de tcp_ip_es
tcp_ip_es tcp_ip_es is offline
No confirmado
 
Registrado: ago 2003
Ubicación: Madrid
Posts: 635
Reputación: 0
tcp_ip_es Va por buen camino
existe un begin mal puesto...a parte el ramdom de 5 puede darte valor 0 y no lo tienes contemplado...mejor ponerlo a 4 ... el procedure quedaría asi.

Código Delphi [-]
procedure TForm1.EditPreguntaKeyPress(Sender: TObject; var Key: Char);
var
 respuesta : Integer;
 RespuestaCAD : String;
begin
 If key=#13 then
 begin
  Table1.Open;
  If Table1.Locate('pregunta',EditPregunta.Text, [loCaseInsensitive]) then
  begin
   Randomize;
   respuesta := Random(4);
   Case respuesta of
    0: RespuestaCAD := Table1.fieldByName('respuesta1').AsString;
    1: RespuestaCAD := Table1.fieldByName('respuesta2').AsString;
    2: RespuestaCAD := Table1.fieldByName('respuesta3').AsString;
    3: RespuestaCAD := Table1.fieldByName('respuesta4').AsString;
    4: RespuestaCAD := Table1.fieldByName('respuesta5').AsString;
   end;
   Table1.Close;
   ListBox1.Items.Add(EditPregunta.Text);
   ListBox1.Items.Add(RespuestaCAD);
   EditPregunta.Text :='';
  end;
 end;
end;
Responder Con Cita