Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Базы";
Текущий архив: 2002.04.29;
Скачать: [xml.tar.bz2];

Вниз

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

 
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;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.49 MB
Время: 0.005 c
1-94484
Чел - программер
2002-04-16 14:56
2002.04.29
НАРОД! Кто-нибудь знает, как обратиться к строке в memo, не ...


1-94405
heruvim4ik
2002-04-17 22:21
2002.04.29
Password Char


3-94278
Malyatko
2002-04-08 12:48
2002.04.29
Добавление в базу данных.


14-94561
Rammst
2002-03-24 06:41
2002.04.29
HELP!


1-94444
Voldemar
2002-04-15 01:29
2002.04.29
Подскажите диалог...





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский