Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

incrementing score board

Status
Not open for further replies.

Spider

Programmer
Sep 3, 1998
3
US
hi. could someone take a look at this code and set me on the right track. i should imagine this stuff is playschool for you guys so any help is very appreciated.

var i : Char;

begin
with Questions[1] do
begin
i := 'F';
if i = 'B' then
begin
Correct := Correct + 1;
end
else
begin
Wrong := Wrong + 1;
end;
end;
with Questions[2] do
begin
i := 'F';
if i = 'D' then
begin
Correct := Correct + 1;
end
else
begin
Wrong := Wrong + 1;
end;
end;


im am trying to increase a score board every time someone answers a question correctly or incorrectly. all this code does is increase the incorrect score by 10( there are ten questions) even if the correct answer is clicked. there are five buttons labeled A-E. the buttons are represented by i. sorry if this seems really simple or if you need more of my code to understand what im on about :eek:) just tell me.
 
i := 'F';
if i = 'B' then

You're assigning 'F' to the variable i before the if statement, so i will never be 'B' (or 'D')
I'm guessing you just want to remove lines
i := 'F'
 
yeah but when i take it away it says that i might not have been initialised.
 
var Column : Integer;
var Row : Integer;
var i : Char;
begin
FrmQuiz.lblQuestion.Caption := 'Welcome to my Quiz please press begin';
Row := 0;
Column := 0;
for i := 'A' to 'F' do
begin
cmdLetters:= TButton.Create(FrmQuiz);
with cmdLetters do
begin
Caption:= i;
Top := 25* Row;
Left := 25* Column;
Height := 25;
Width := 25;
OnClick := FrmQuiz.btnLetterClick;
Parent := pnlAnswers;
Row:= Row + 2;
if Column = 2.5 then
begin
Column := Column + 1;
Row := 0;
DisplayScore();
end;
end;
end;
end;

this is the code for the buttons to be created. does this help you understand what i mean ??
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top