Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.04.29;
Скачать: CL | DM;

Вниз

Обсуждение рендома и фора.....   Найти похожие ветки 

 
valievrf ©   (2002-04-07 17:02) [0]

постановка задачи... достать из БД на 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;



Анатолий, так или нет так???


 
Anatoly Podgoretsky ©   (2002-04-07 17:11) [1]

N := Table1.RecordsCount /100*80


 
valievrf ©   (2002-04-07 17:13) [2]

и все???


 
Anatoly Podgoretsky ©   (2002-04-07 17:15) [3]

Нет я дальше этой строчки не смотрел


 
valievrf ©   (2002-04-07 17:53) [4]

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т ысчелкаешь, он его показывает три раза, ты счелкаешь, а вопросы меняются.... вот в чем напряг. может я где то не то вписал??


 
KaPaT ©   (2002-04-07 17:56) [5]

Напряг в том что ShowMessage в цикле стоит


 
dymka ©   (2002-04-07 17:56) [6]

я не понял вопроса, и не понял зачем надо делать так:
N := Table1.RecordsCount /100*80;


 
Anatoly Podgoretsky ©   (2002-04-07 17:57) [7]

Правильнь, ты же в цикле выводишь диалог, а не нужно?


 
valievrf ©   (2002-04-07 18:04) [8]

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;
Что и получиолось, значит диалоги убрать???


 
valievrf ©   (2002-04-07 18:09) [9]


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:10) [10]

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;


 
KaPaT ©   (2002-04-07 18:19) [11]

Про твою организацию программы!
Сделай кнопочку "Next" (следующий вопрос)! В ней и обрабатывай выборку вопроса с помощью Random и FindKey


 
valievrf ©   (2002-04-07 18:20) [12]


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.



 
Anatoly Podgoretsky ©   (2002-04-07 18:21) [13]

И есло QCounter > N


 
valievrf ©   (2002-04-07 18:30) [14]

А теперь он что хочет ???
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;
пока трижды не кликнешь -моросит....


 
valievrf ©   (2002-04-07 18:35) [15]

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:42) [16]

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.



Страницы: 1 вся ветка

Текущий архив: 2002.04.29;
Скачать: CL | DM;

Наверх




Память: 0.51 MB
Время: 0.013 c
1-94436
Fast
2002-04-15 19:28
2002.04.29
кодировка


3-94329
Makuha
2002-04-09 16:28
2002.04.29
Не могу правильно задать вопрос (смотри текст письма)


1-94364
KvORubin
2002-04-16 09:15
2002.04.29
Как коректно дать комманду с одной на другую *.EXE


6-94528
Lenidus
2002-02-17 14:10
2002.04.29
Чем заменить компонент TWebBrowser?


4-94626
Nuhim
2002-02-22 10:43
2002.04.29
Как перехватить уход мыши в правый край экрана