![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Обсуждение рендома и фора..... [D5, Paradox]
valievrf © (2002-04-07 17:02:00)постановка задачи... достать из БД на 700 вопросов 80 либо количествоуказанное мгнеой в хаотическом порядке...
Пример кода который бы написал я... ИСПРАВИТЕ
begin
N := .RecordsCount /100*80
for I := 1 to N do
if Table1.FieldByName("Right").Value = Edit1.text then
begin
Balls:=StrToInt(Table1.FieldByName("Ball").Value) + Balls;
ShowMessage(IntToStr(Balls));
end
else
ShowMessage("Неверно");
Table1.Next;
end;
end;
Анатолий, так или нет так???
valievrf (2002-04-07 18:42:00) [1]
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, DBCtrls, Db, DBTables;
type
TForm4 = class(TForm)
DBMemo1: TDBMemo;
DataSource1: TDataSource;
Table1: TTable;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
DBText1: TDBText;
DBText2: TDBText;
DBText3: TDBText;
DBText4: TDBText;
RadioGroup1: TRadioGroup;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
DBMemo2: TDBMemo;
Label7: TLabel;
DBText5: TDBText;
Label8: TLabel;
Label9: TLabel;
Timer1: TTimer;
Edit1: TEdit;
Label10: TLabel;
Shape1: TShape;
Label11: TLabel;
Button1: TButton;
procedure FormActivate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
Balls:integer;
i:integer;
proideno:integer;
implementation
uses Unit1;
{$R *.DFM}
procedure TForm4.FormActivate(Sender: TObject);
begin
Form1.visible:=false;
RadioButton2.Checked:=true;
end;
procedure TForm4.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Form1.visible:=true;
end;
procedure TForm4.RadioButton1Click(Sender: TObject);
begin
DBMemo2.visible:=true;
DBText5.visible:=true;
end;
procedure TForm4.RadioButton2Click(Sender: TObject);
begin
DBmemo2.visible:=false;
DBText5.visible:=false;
end;
procedure TForm4.Timer1Timer(Sender: TObject);
begin
Label11.caption:=TimeToStr(Time);
end;
procedure TForm4.Button1Click(Sender: TObject);
begin
if proideno >=3 then ShowMessage(IntToStr(Balls))
else
begin
proideno:=1+proideno;
Table1.FindKey([Random(7)]);
if Table1.FieldByName("Right").Value = Edit1.text then
Balls:=StrToInt(Table1.FieldByName("Ball").Value) + Balls;
end;
end;
procedure TForm4.FormCreate(Sender: TObject);
begin
Table1.FindKey([Random(7)]);
end;
end.
valievrf (2002-04-07 18:35:00) [2]begin
if proideno >=3 then ShowMessage(IntToStr(Balls))
else
begin
proideno:=1+proideno;
Table1.FindKey([Random(7)]);
if Table1.FieldByName("Right").Value = Edit1.text then
Balls:=StrToInt(Table1.FieldByName("Ball").Value) + Balls;
end;
end;
valievrf (2002-04-07 18:30:00) [3]А теперь он что хочет ???
begin
if proideno >=3 then ShowMessage(IntToStr(Balls))
else
proideno:=1+proideno;
Table1.FindKey([Random(7)]);
if Table1.FieldByName("Right").Value = Edit1.text then
Balls:=StrToInt(Table1.FieldByName("Ball").Value) + Balls;
end;
пока трижды не кликнешь -моросит....
Anatoly Podgoretsky (2002-04-07 18:21:00) [4]И есло QCounter > N
valievrf (2002-04-07 18:20:00) [5]
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, DBCtrls, Db, DBTables;
type
TForm4 = class(TForm)
DBMemo1: TDBMemo;
DataSource1: TDataSource;
Table1: TTable;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
DBText1: TDBText;
DBText2: TDBText;
DBText3: TDBText;
DBText4: TDBText;
RadioGroup1: TRadioGroup;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
DBMemo2: TDBMemo;
Label7: TLabel;
DBText5: TDBText;
Label8: TLabel;
Label9: TLabel;
Timer1: TTimer;
Edit1: TEdit;
Label10: TLabel;
Shape1: TShape;
Label11: TLabel;
Button1: TButton;
procedure FormActivate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
Balls:integer;
i:integer;
n:integer;
implementation
uses Unit1;
{$R *.DFM}
procedure TForm4.FormActivate(Sender: TObject);
begin
Form1.visible:=false;
RadioButton2.Checked:=true;
end;
procedure TForm4.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Form1.visible:=true;
end;
procedure TForm4.RadioButton1Click(Sender: TObject);
begin
DBMemo2.visible:=true;
DBText5.visible:=true;
end;
procedure TForm4.RadioButton2Click(Sender: TObject);
begin
DBmemo2.visible:=false;
DBText5.visible:=false;
end;
procedure TForm4.Timer1Timer(Sender: TObject);
begin
Label11.caption:=TimeToStr(Time);
end;
procedure TForm4.Button1Click(Sender: TObject);
begin
for i:= 1 to 3 do
begin
Table1.FindKey([Random(7)]);
if Table1.FieldByName("Right").Value = Edit1.text then
Balls:=StrToInt(Table1.FieldByName("Ball").Value) + Balls;
end;
ShowMessage(IntToStr(Balls));
end;
end.
KaPaT (2002-04-07 18:19:00) [6]Про твою организацию программы!
Сделай кнопочку "Next" (следующий вопрос)! В ней и обрабатывай выборку вопроса с помощью Random и FindKey
valievrf (2002-04-07 18:10:00) [7]begin
for i:= 1 to 3 do
begin
Table1.FindKey([Random(7)]);
if Table1.FieldByName("Right").Value = Edit1.text then
Balls:=StrToInt(Table1.FieldByName("Ball").Value) + Balls;
end;
ShowMessage(IntToStr(Balls));
end;
valievrf (2002-04-07 18:09:00) [8]
begin
Table1.FindKey([Random(7)]);
if Table1.FieldByName("Right").Value = Edit1.text then
Balls:=StrToInt(Table1.FieldByName("Ball").Value) + Balls;
end;
ShowMessage(IntToStr(Balls));
end;
valievrf (2002-04-07 18:04:00) [9]begin
for i:= 1 to 3 do
begin
Table1.FindKey([Random(7)]);
if Table1.FieldByName("Right").Value = Edit1.text then
begin
Balls:=StrToInt(Table1.FieldByName("Ball").Value) + Balls;
ShowMessage(IntToStr(Balls));
end
else
ShowMessage("Неверно");
end;
end;
Что и получиолось, значит диалоги убрать???
Anatoly Podgoretsky (2002-04-07 17:57:00) [10]Правильнь, ты же в цикле выводишь диалог, а не нужно?
KaPaT (2002-04-07 17:56:00) [11]Напряг в том что ShowMessage в цикле стоит
dymka (2002-04-07 17:56:00) [12]я не понял вопроса, и не понял зачем надо делать так:
N := Table1.RecordsCount /100*80;
valievrf (2002-04-07 17:53:00) [13]
procedure TForm4.Button1Click(Sender: TObject);
begin
Table1.FindKey([Random(7)]);
for i:= 1 to 3 do
begin
if Table1.FieldByName("Right").Value = Edit1.text then
begin
Balls:=StrToInt(Table1.FieldByName("Ball").Value) + Balls;
ShowMessage(IntToStr(Balls));
end
else
ShowMessage("Неверно");
Table1.Next;
end;
end;
Теперь другая проблема, выводит ответ через ShowMessageт ысчелкаешь, он его показывает три раза, ты счелкаешь, а вопросы меняются.... вот в чем напряг. может я где то не то вписал??
Anatoly Podgoretsky (2002-04-07 17:15:00) [14]Нет я дальше этой строчки не смотрел
valievrf (2002-04-07 17:13:00) [15]и все???
Anatoly Podgoretsky (2002-04-07 17:11:00) [16]N := Table1.RecordsCount /100*80