Jump to content


Check out our Community Blogs

Sparky

Member Since 23 Sep 2008
Offline Last Active Oct 16 2008 06:53 AM
-----

Posts I've Made

In Topic: Help! Rlink32 Error

16 October 2008 - 05:27 AM

Hi

Sorry That I was not on for a while but my Internet connection was down.

I solved the problem by replacing the files with older backup ones that do work, I had to only recode some things.

At the moment I'm having the same problem with another file, but it is not the only one, and when I restart it sometimes works other times gives the error, but when I modify it the time it works it causes windows to have a blue screen. IT may have something to do with the users(other forms launching from that form), but I doubt it. I open the .dfm, but Ive never modified the file's i don't know how to use it and prefer the GUI interface. The file has also worked fine until it as above suddenly restarts when Delphi stops responding and causes windows to have a memory read error. If I delete the users line, the program asks if i would like to add the unit to it again and then it displays the file path error instead. Then when I reopen the project, it complains that a curtain line is the problem. If I go into the .dfm and look for the line and then go back to the form and delete the object that is causing it(the object is 32bit and worked for a long time) it complains that the next line has a problem. It therefore has a 16bit error with the next object. Which in one case was Delphi's image component.

If you need the .dfm ask, but it is long or tell me which part you need. This problem occurs on every computer. I also wonder if windows is missing a file as when I try run a backup - backup copy on another computer it works, but is till does not work on mine, must I re-install delphi, replace a windows file (tell me if this is the case) or it may be the program at fault.

I hope this is in enough detail

In Topic: Help! Rlink32 Error

13 October 2008 - 09:30 AM

Hi

This is my code. It is only the base one as you can see through the repetition. I tried in the mean time to change the random numbers back to the original which is //(20)// but the it gives the Rlink error of the possition of the file eg:// C:Documentsandsettings... filename//. Forgive me for not editing the code so that you can understand what is going on in more detail, but contact me it you need a better explaination.
//unit assignment4_MDJ_u;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls;

type
  TfrmIntermediate = class(TForm)
    imgBackRound: TImage;
    imgWrong: TImage;
    imgCorrect: TImage;
    lblTime: TLabel;
    gbMultiply: TGroupBox;
    lbltotalcomple: TLabel;
    BitBtnMultiply: TBitBtn;
    gbAdd: TGroupBox;
    lblTotalcomp: TLabel;
    BitBtnAdd: TBitBtn;
    gbSubtract: TGroupBox;
    lbltotalcompl: TLabel;
    BitBtnSubtract: TBitBtn;
    gbDivide: TGroupBox;
    lbltotalcomplet: TLabel;
    BitBtnDivide: TBitBtn;
    gbChoice2: TGroupBox;
    btnAdd: TButton;
    btnMutiply: TButton;
    btnSubtraction: TButton;
    btnDivide: TButton;
    BitBtnCancel: TBitBtn;
    BitBtnBack: TBitBtn;
    pnlClosePage: TPanel;
    lblExit: TLabel;
    ImgSad: TImage;
    BitBtnNo: TBitBtn;
    BitBtnYes: TBitBtn;
    bmbScores: TBitBtn;
    gbPlayer: TGroupBox;
    lblPlayer: TLabel;
    bmbplayer1: TBitBtn;
    bmbPlayer2: TBitBtn;
    bmbplayer3: TBitBtn;
    bmbplayer4: TBitBtn;
    bmbplayer5: TBitBtn;
    bmbplayer6: TBitBtn;
    PnlTotalans: TPanel;
    lblTotalwrong: TLabel;
    lblTotalCorr: TLabel;
    lblTotal: TLabel;
    pnl1: TPanel;
    lbl1: TLabel;
    lbl2: TLabel;
    lbl3: TLabel;
    pnl3: TPanel;
    lbl7: TLabel;
    lbl8: TLabel;
    lbl9: TLabel;
    pnl5: TPanel;
    lbl13: TLabel;
    lbl14: TLabel;
    lbl15: TLabel;
    pnl2: TPanel;
    lbl4: TLabel;
    lbl5: TLabel;
    lbl6: TLabel;
    pnl4: TPanel;
    lbl10: TLabel;
    lbl11: TLabel;
    lbl12: TLabel;
    tmSystem: TTimer;
    procedure bmbScoresClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure BitBtnAddClick(Sender: TObject);
    procedure BitBtnAddMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure BitBtnMultiplyClick(Sender: TObject);
    procedure BitBtnMultiplyMouseMove(Sender: TObject; Shift: TShiftState;
      X, Y: Integer);
    procedure BitBtnSubtractClick(Sender: TObject);
    procedure BitBtnSubtractMouseMove(Sender: TObject; Shift: TShiftState;
      X, Y: Integer);
    procedure BitBtnDivideClick(Sender: TObject);
    procedure BitBtnDivideMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure bmbPlayer2Click(Sender: TObject);
    procedure bmbplayer3Click(Sender: TObject);
    procedure bmbplayer4Click(Sender: TObject);
    procedure bmbplayer5Click(Sender: TObject);
    procedure bmbplayer6Click(Sender: TObject);
    procedure BitBtnYesClick(Sender: TObject);
    procedure BitBtnNoClick(Sender: TObject);
    procedure btnAddClick(Sender: TObject);
    procedure btnMutiplyClick(Sender: TObject);
    procedure btnSubtractionClick(Sender: TObject);
    procedure btnDivideClick(Sender: TObject);
    procedure BitBtnCancelClick(Sender: TObject);
    procedure bmbplayer1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmIntermediate: TfrmIntermediate;
  inputstr : string;
    iRight, iWrong, iRightAll, iWrongAll, iadd1, iadd2,iresult, iresult2: Integer;
    player : integer;

implementation

uses assignment2_MDJ_u, assignment9_MDJ_u, assignment3_MDJ_u,
  assignment7_MDJ_u, assignment10_MDJ_u;

{$R *.dfm}
procedure sub;
begin
repeat
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
until iadd1 > iadd2;
if iadd1 > iadd2 then
iResult := iAdd1 - iAdd2 else
iAdd2 := Random(20) + 1;
end;

procedure TfrmIntermediate.bmbScoresClick(Sender: TObject);
begin
frmIntermediate.Visible := False;
frmIntermediateScore.Visible := True;
if strtoint(lbltotalcorr.Caption) > (strtoint(lbl1.Caption) and strtoint(lbl4.Caption) and strtoint(lbl7.Caption)
and strtoint(lbl10.Caption) and strtoint(lbl13.Caption)) then begin
frmIntermediateScore.pnlHigh.Visible := True;
frmIntermediateScore.lblName.Caption := frmName.EdtName1.Text;
frmIntermediateScore.lblScore.Caption := frmIntermediate.lblTotalCorr.Caption;
end
else begin
if strtoint(lbl1.Caption) > (strtoint(lbltotalcorr.Caption) and strtoint(lbl4.Caption) and strtoint(lbl7.Caption)
and strtoint(lbl10.Caption) and strtoint(lbl13.Caption)) then begin
frmIntermediateScore.pnlHigh.Visible := True;
frmIntermediateScore.lblName.Caption := frmName.EdtName2.Text;
frmIntermediateScore.lblScore.Caption := frmIntermediate.lbl1.Caption;
end
else begin
if strtoint(lbl4.Caption) > (strtoint(lbltotalcorr.Caption) and strtoint(lbl1.Caption) and strtoint(lbl7.Caption)
and strtoint(lbl10.Caption) and strtoint(lbl13.Caption)) then begin
frmIntermediateScore.pnlHigh.Visible := True;
frmIntermediateScore.lblName.Caption := frmName.EdtName3.Text;
frmIntermediateScore.lblScore.Caption := frmIntermediate.lbl4.Caption;
end
else begin
if strtoint(lbl7.Caption) > (strtoint(lbltotalcorr.Caption) and strtoint(lbl1.Caption) and strtoint(lbl4.Caption)
and strtoint(lbl10.Caption) and strtoint(lbl13.Caption)) then begin
frmIntermediateScore.pnlHigh.Visible := True;
frmIntermediateScore.lblName.Caption := frmName.EdtName4.Text;
frmIntermediateScore.lblScore.Caption := frmIntermediate.lbl7.Caption;
end
else begin
if strtoint(lbl10.Caption) > (strtoint(lbltotalcorr.Caption) and strtoint(lbl1.Caption) and strtoint(lbl4.Caption)
and strtoint(lbl7.Caption) and strtoint(lbl13.Caption)) then begin
frmIntermediateScore.pnlHigh.Visible := True;
frmIntermediateScore.lblName.Caption := frmName.EdtName5.Text;
frmIntermediateScore.lblScore.Caption := frmIntermediate.lbl10.Caption;
end
else begin
if strtoint(lbl13.Caption) > (strtoint(lbltotalcorr.Caption) and strtoint(lbl1.Caption) and strtoint(lbl4.Caption)
and strtoint(lbl7.Caption) and strtoint(lbl10.Caption)) then begin
frmIntermediateScore.pnlHigh.Visible := True;
frmIntermediateScore.lblName.Caption := frmName.EdtName6.Text;
frmIntermediateScore.lblScore.Caption := frmIntermediate.lbl13.Caption;
end
else begin
frmscoresenior.pnlHigh.Visible := False;
end;
end;
end;
end;
end;
end;

end;


procedure TfrmIntermediate.FormActivate(Sender: TObject);
begin
iRightAll := 0;
iRightAll := 0;
iRight := 0;
iWrong := 0;
frmPrimary.Brush.Color := clBtnFace;
lbltotalcorr.Caption := '0';
lblTotalwrong.Caption := '0';
lblTotal.Caption := '0';
lbl1.Caption := '0';
lbl2.Caption := '0';
lbl3.Caption := '0';
lbl4.Caption := '0';
lbl5.Caption := '0';
lbl6.Caption := '0';
lbl7.Caption := '0';
lbl8.Caption := '0';
lbl9.Caption := '0';
lbl10.Caption := '0';
lbl11.Caption := '0';
lbl12.Caption := '0';
lbl13.Caption := '0';
lbl14.Caption := '0';
lbl15.Caption := '0';
end;

procedure TfrmIntermediate.BitBtnAddClick(Sender: TObject);
var
A, icounter : integer;
begin
icounter := 0;
if player = 1 then
for A := 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 + iAdd2;
Inputstr := InputBox('Addition [ + ]', IntToStr(iAdd1) +  '+' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  inc(iRight,1) else
  inc(iWrong,1);
      If StrToInt(Inputstr) = iResult then
      showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
      showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lblTotalCorr.Caption :=  IntToStr(iRightAll) else
              lblTotalwrong.Caption := IntToStr(iWrongAll);
              lblTotal.Caption := IntToStr(iRight + iWrong);
               iCounter := icounter + 1;
               lblTotalcomp.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 2 then
for A := 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 + iAdd2;
Inputstr := InputBox('Addition [ + ]', IntToStr(iAdd1) +  '+' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  inc(iRight,1) else
  inc(iWrong,1);
      If StrToInt(Inputstr) = iResult then
      showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
      showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl1.Caption :=  IntToStr(iRightAll) else
              lbl2.Caption := IntToStr(iWrongAll);
              lbl3.Caption := IntToStr(iRight + iWrong);
               iCounter := icounter + 1;
               lblTotalcomp.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 3 then
for A := 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 + iAdd2;
Inputstr := InputBox('Addition [ + ]', IntToStr(iAdd1) +  '+' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  inc(iRight,1) else
  inc(iWrong,1);
      If StrToInt(Inputstr) = iResult then
      showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
      showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl4.Caption :=  IntToStr(iRightAll) else
              lbl5.Caption := IntToStr(iWrongAll);
              lbl6.Caption := IntToStr(iRight + iWrong);
               iCounter := icounter + 1;
               lblTotalcomp.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 4 then
for A := 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 + iAdd2;
Inputstr := InputBox('Addition [ + ]', IntToStr(iAdd1) +  '+' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  inc(iRight,1) else
  inc(iWrong,1);
      If StrToInt(Inputstr) = iResult then
      showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
      showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl7.Caption :=  IntToStr(iRightAll) else
              lbl8.Caption := IntToStr(iWrongAll);
              lbl9.Caption := IntToStr(iRight + iWrong);
               iCounter := icounter + 1;
               lblTotalcomp.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 5 then
for A := 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 + iAdd2;
Inputstr := InputBox('Addition [ + ]', IntToStr(iAdd1) +  '+' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  inc(iRight,1) else
  inc(iWrong,1);
      If StrToInt(Inputstr) = iResult then
      showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
      showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
       If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl10.Caption :=  IntToStr(iRightAll) else
              lbl11.Caption := IntToStr(iWrongAll);
              lbl12.Caption := IntToStr(iRight + iWrong);
               iCounter := icounter + 1;
               lblTotalcomp.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 6 then
for A := 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 + iAdd2;
Inputstr := InputBox('Addition [ + ]', IntToStr(iAdd1) +  '+' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  inc(iRight,1) else
  inc(iWrong,1);
      If StrToInt(Inputstr) = iResult then
      showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
      showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl13.Caption :=  IntToStr(iRightAll) else
              lbl14.Caption := IntToStr(iWrongAll);
              lbl15.Caption := IntToStr(iRight + iWrong);
               iCounter := icounter + 1;
               lblTotalcomp.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;

end;

procedure TfrmIntermediate.BitBtnAddMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
imgCorrect.Visible := False;
imgWrong.Visible := False;
end;

procedure TfrmIntermediate.BitBtnMultiplyClick(Sender: TObject);
var
A, iCounter : integer;
begin
icounter := 0;
if player = 1 then
For A:= 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 * iAdd2;
Inputstr := InputBox('Multiplication [ x ]', IntToStr(iAdd1) +  'x' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  iRight := (iRight  + 1) else
  iRight := (iRight  + 1);
      If StrToInt(Inputstr) = iResult then
      showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
      showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lblTotalCorr.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
              lblTotalwrong.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
              lblTotal.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
              iCounter := icounter + 1;
               lblTotalcomple.Caption := 'Number of sums complted: ' + inttostr(iCounter);

end;
if player = 2 then
For A:= 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 * iAdd2;
Inputstr := InputBox('Multiplication [ x ]', IntToStr(iAdd1) +  'x' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  iRight := (iRight  + 1) else
  iRight := (iRight  + 1);
      If StrToInt(Inputstr) = iResult then
      showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
      showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl1.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
              lbl2.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
              lbl3.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
              iCounter := icounter + 1;
               lblTotalcomple.Caption := 'Number of sums complted: ' + inttostr(iCounter);

end;
if player = 3 then
For A:= 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 * iAdd2;
Inputstr := InputBox('Multiplication [ x ]', IntToStr(iAdd1) +  'x' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  iRight := (iRight  + 1) else
  iRight := (iRight  + 1);
      If StrToInt(Inputstr) = iResult then
      showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
      showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
       If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl4.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
              lbl5.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
              lbl6.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
              iCounter := icounter + 1;
               lblTotalcomple.Caption := 'Number of sums complted: ' + inttostr(iCounter);

end;
if player = 4 then
For A:= 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 * iAdd2;
Inputstr := InputBox('Multiplication [ x ]', IntToStr(iAdd1) +  'x' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  iRight := (iRight  + 1) else
  iRight := (iRight  + 1);
      If StrToInt(Inputstr) = iResult then
      showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
      showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl7.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
              lbl8.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
              lbl9.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
              iCounter := icounter + 1;
               lblTotalcomple.Caption := 'Number of sums complted: ' + inttostr(iCounter);

end;
if player = 5 then
For A:= 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 * iAdd2;
Inputstr := InputBox('Multiplication [ x ]', IntToStr(iAdd1) +  'x' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  iRight := (iRight  + 1) else
  iRight := (iRight  + 1);
      If StrToInt(Inputstr) = iResult then
      showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
      showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl10.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
              lbl11.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
              lbl12.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
              iCounter := icounter + 1;
               lblTotalcomple.Caption := 'Number of sums complted: ' + inttostr(iCounter);

end;
if player = 6 then
For A:= 1 to 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult := iAdd1 * iAdd2;
Inputstr := InputBox('Multiplication [ x ]', IntToStr(iAdd1) +  'x' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  iRight := (iRight  + 1) else
  iRight := (iRight  + 1);
      If StrToInt(Inputstr) = iResult then
      showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
      showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl13.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
              lbl14.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
              lbl15.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
              iCounter := icounter + 1;
               lblTotalcomple.Caption := 'Number of sums complted: ' + inttostr(iCounter);

end;

end;


procedure TfrmIntermediate.BitBtnMultiplyMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
imgCorrect.Visible := False;
imgWrong.Visible := False;
end;

procedure TfrmIntermediate.BitBtnSubtractClick(Sender: TObject);
var
icounter : integer;
begin
icounter := 0;
if player = 1 then
while icounter < 10 do
begin
sub;
Inputstr := InputBox('Subtraction [ - ]', IntToStr(iAdd1) +  '-' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  inc(iRight,1) else
  inc(iWrong,1);
      If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
        showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
        showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lblTotalCorr.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
              lblTotalwrong.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
              lblTotal.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
              iCounter := icounter + 1;
               lblTotalcompl.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 2 then
while icounter < 10 do
begin
sub;
Inputstr := InputBox('Subtraction [ - ]', IntToStr(iAdd1) +  '-' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  inc(iRight,1) else
  inc(iWrong,1);
      If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
        showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
        showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl1.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
              lbl2.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
              lbl3.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
              iCounter := icounter + 1;
               lblTotalcompl.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 3 then
while icounter < 10 do
begin
sub;
Inputstr := InputBox('Subtraction [ - ]', IntToStr(iAdd1) +  '-' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  inc(iRight,1) else
  inc(iWrong,1);
      If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
        showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
        showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl4.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
              lbl5.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
              lbl6.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
              iCounter := icounter + 1;
               lblTotalcompl.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 4 then
while icounter < 10 do
begin
sub;
Inputstr := InputBox('Subtraction [ - ]', IntToStr(iAdd1) +  '-' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  inc(iRight,1) else
  inc(iWrong,1);
      If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
        showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
        showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl7.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
              lbl8.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
              lbl9.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
              iCounter := icounter + 1;
               lblTotalcompl.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 5 then
while icounter < 10 do
begin
sub;
Inputstr := InputBox('Subtraction [ - ]', IntToStr(iAdd1) +  '-' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  inc(iRight,1) else
  inc(iWrong,1);
      If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
        showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
        showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl10.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
              lbl11.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
              lbl12.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
              iCounter := icounter + 1;
               lblTotalcompl.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
if player = 6 then
while icounter < 10 do
begin
sub;
Inputstr := InputBox('Subtraction [ - ]', IntToStr(iAdd1) +  '-' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  inc(iRight,1) else
  inc(iWrong,1);
      If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
        showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
        showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl13.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
              lbl14.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
              lbl15.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
              iCounter := icounter + 1;
               lblTotalcompl.Caption := 'Number of sums complted: ' + inttostr(iCounter);
end;
end;

procedure TfrmIntermediate.BitBtnSubtractMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
imgCorrect.Visible := False;
imgWrong.Visible := False;
end;

procedure TfrmIntermediate.BitBtnDivideClick(Sender: TObject);
var
counter : integer;
begin
counter := 0;
if player = 1 then
while Counter < 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult2 := iAdd1 * iAdd2;
iResult :=  iResult2 div iadd2;
Inputstr := InputBox('Addition [ / ]', IntToStr(iresult2) +  '/' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  inc(iRight,1) else
  inc(iWrong,1);
      If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
        showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
        showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl1.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
              lbl2.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
             lbl3.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
               counter := counter + 1;
               lbltotalcomplet.Caption := 'Number of sums complted: ' + inttostr(counter);
end;
if player = 2 then
while Counter < 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult2 := iAdd1 * iAdd2;
iResult :=  iResult2 div iadd2;
Inputstr := InputBox('Addition [ / ]', IntToStr(iresult2) +  '/' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  inc(iRight,1) else
  inc(iWrong,1);
      If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
        showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
        showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl4.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
              lbl5.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
             lbl6.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
               counter := counter + 1;
               lbltotalcomplet.Caption := 'Number of sums complted: ' + inttostr(counter);
end;
if player = 3 then
while Counter < 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult2 := iAdd1 * iAdd2;
iResult :=  iResult2 div iadd2;
Inputstr := InputBox('Addition [ / ]', IntToStr(iresult2) +  '/' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  inc(iRight,1) else
  inc(iWrong,1);
      If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
        showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
        showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl7.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
              lbl8.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
             lbl9.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
               counter := counter + 1;
               lbltotalcomplet.Caption := 'Number of sums complted: ' + inttostr(counter);
end;
if player = 4 then
while Counter < 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult2 := iAdd1 * iAdd2;
iResult :=  iResult2 div iadd2;
Inputstr := InputBox('Addition [ / ]', IntToStr(iresult2) +  '/' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  inc(iRight,1) else
  inc(iWrong,1);
      If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
        showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
        showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl10.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
              lbl11.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
             lbl12.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
               counter := counter + 1;
               lbltotalcomplet.Caption := 'Number of sums complted: ' + inttostr(counter);
end;
if player = 5 then
while Counter < 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult2 := iAdd1 * iAdd2;
iResult :=  iResult2 div iadd2;
Inputstr := InputBox('Addition [ / ]', IntToStr(iresult2) +  '/' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  inc(iRight,1) else
  inc(iWrong,1);
      If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
        showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
        showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lbl13.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
              lbl14.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
             lbl15.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
               counter := counter + 1;
               lbltotalcomplet.Caption := 'Number of sums complted: ' + inttostr(counter);
end;
if player = 6 then
while Counter < 10 do
begin
Randomize;
iAdd1 := Random(20) + 1;
iAdd2 := Random(20) + 1;
iResult2 := iAdd1 * iAdd2;
iResult :=  iResult2 div iadd2;
Inputstr := InputBox('Addition [ / ]', IntToStr(iresult2) +  '/' + IntToStr(iAdd2) + ' - Always put in a Answer','0');
  If StrToInt(Inputstr) = iResult then
  inc(iRight,1) else
  inc(iWrong,1);
      If StrToInt(Inputstr) = iResult
        then  begin
        imgCorrect.Visible := True;
        imgWrong.Visible := False;
        end;
        If StrToInt(Inputstr) <> iResult
        then begin
        imgCorrect.Visible := False;
        imgWrong.Visible := True;
        end;
        If StrToInt(Inputstr) = iResult then
        showmessage('Welldone!!! It is ' + IntToStr(iresult)) else
        showmessage('Better Luck Next time! The answer is: ' + IntToStr(iresult));
        If StrToInt(Inputstr) = iResult then
            inc(iRightAll,1) else
            inc(iWrongAll,1);
              if StrToInt(Inputstr) = iResult  then
              lblTotalCorr.Caption := 'Total number of Correct Answers: ' + IntToStr(iRightAll) else
              lblTotalwrong.Caption := 'Total number of Incorrect Answers: ' + IntToStr(iWrongAll);
             lblTotal.Caption := 'Total sums Completed: ' + IntToStr(iRight + iWrong);
               counter := counter + 1;
               lbltotalcomplet.Caption := 'Number of sums complted: ' + inttostr(counter);
end;
end;


procedure TfrmIntermediate.BitBtnDivideMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
imgCorrect.Visible := False;
imgWrong.Visible := False;
end;

procedure TfrmIntermediate.bmbPlayer2Click(Sender: TObject);
begin
gbchoice2.Visible := True;
gbPlayer.Visible := False;
player := 2;
end;

procedure TfrmIntermediate.bmbplayer3Click(Sender: TObject);
begin
gbchoice2.Visible := True;
gbPlayer.Visible := False;
player := 3;
end;

procedure TfrmIntermediate.bmbplayer4Click(Sender: TObject);
begin
gbchoice2.Visible := True;
gbPlayer.Visible := False;
player := 4;
end;

procedure TfrmIntermediate.bmbplayer5Click(Sender: TObject);
begin
gbchoice2.Visible := True;
gbPlayer.Visible := False;
player := 5;
end;

procedure TfrmIntermediate.bmbplayer6Click(Sender: TObject);
begin
gbchoice2.Visible := True;
gbPlayer.Visible := False;
player := 6;
end;

procedure TfrmIntermediate.BitBtnYesClick(Sender: TObject);
begin
  gbAdd.Visible := false;
  gbSubtract.Visible := False;
  gbMultiply.Visible := False;
  frmPhase.Show;
  pnlClosePage.Visible := False;
  frmPrimary.Visible := False;
  imgCorrect.Visible := False;
  imgWrong.Visible := True;
end;

procedure TfrmIntermediate.BitBtnNoClick(Sender: TObject);
begin
pnlClosePage.Visible := False;
bitbtnBack.Visible := True;
end;

procedure TfrmIntermediate.btnAddClick(Sender: TObject);
begin
gbAdd.Visible := True;
gbChoice2.Visible := False;
bitbtnAdd.Visible := True;
bitbtnback.Visible := True;
imgWrong.Visible := False;
imgCorrect.Visible := False;
end;

procedure TfrmIntermediate.btnMutiplyClick(Sender: TObject);
begin
gbMultiply.Visible := True;
gbChoice2.Visible := False;
bitBtnMultiply.Visible := True;
bitbtnback.Visible := True;
imgWrong.Visible := False;
imgCorrect.Visible := False;
end;

procedure TfrmIntermediate.btnSubtractionClick(Sender: TObject);
begin
gbSubTract.Visible := True;
gbChoice2.Visible := False;
bitbtnSubtract.Visible := True;
imgWrong.Visible := False;
imgCorrect.Visible := False;
end;

procedure TfrmIntermediate.btnDivideClick(Sender: TObject);
begin
gbDivide.Visible := True;
gbChoice2.Visible := False;
bitbtnDivide.Visible := True;
bitbtnback.Visible := True;
imgWrong.Visible := False;
imgCorrect.Visible := False;
end;

procedure TfrmIntermediate.BitBtnCancelClick(Sender: TObject);
begin
frmPhase.Visible := True;
frmPrimary.Visible := False;
end;

procedure TfrmIntermediate.bmbplayer1Click(Sender: TObject);
begin
gbchoice2.Visible := True;
gbPlayer.Visible := False;
player := 1;
end;

end.// 
Ihope this helps.

In Topic: Saving and reading a Text file

29 September 2008 - 10:23 PM

Thanks it works well it was so simple, I'm sorry if I caused any annoyances. I will now remember to use code Tags:)

In Topic: Saving and reading a Text file

27 September 2008 - 11:43 PM

Hi I am now able to save my data to a File as you have seen above. I am using several pages in my program so i am using the show / hide methos to display them. My only problem is that when I but the code in the On show property and on hide property and run the program it gives me the following error (I/O 102) which means file not assigned. I tryed to write test data in the on activate property, it work, but i didnt want fixed data so I deleted it (still in Brackets below). This i though the data should be now saved but when I sstarted it up it gave me the problem as above. The on show property is the error when i used trace into. Could anyone please help me with this problem as still no text books help me and internet codes are not sutable.

Here is my code.

unit assignment12_MDJ_u;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls;

type
  TfrmHigh = class(TForm)
    edtNameinput: TEdit;
    bmbConfirm: TBitBtn;
    ListBox1: TListBox;
    imgBack: TImage;
    procedure FormShow(Sender: TObject);
    procedure FormHide(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure imgBackClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmHigh: TfrmHigh;
   myFile : TextFile;
implementation

uses assignment_MDJ_u;

{$R *.dfm}

procedure TfrmHigh.FormShow(Sender: TObject);
var
   text   : string;
begin
      // Reopen the file for reading
   Reset(myFile);
 
   // Display the file contents
   while not Eof(myFile) do
   begin
     ReadLn(myFile, text);
     listbox1.Items.Add(text);
   end;

   // Close the file for the last time
   CloseFile(myFile);
end;

procedure TfrmHigh.FormHide(Sender: TObject);
var
   text   : string;
begin
   // Try to open the Test.txt file for writing to
   AssignFile(myFile, 'Test.txt');
   ReWrite(myFile);
 
   // Write to this file
   WriteLn(myFile, edtNameinput.text);
   WriteLn(myFile, listbox1.items.add(text));

   // Close the file
   CloseFile(myFile);
end;

procedure TfrmHigh.FormActivate(Sender: TObject);
var
   text   : string;
begin
[COLOR="Lime"]  {[/COLOR] // Try to open the Test.txt file for writing to
   AssignFile(myFile, 'Test.txt');
   ReWrite(myFile);

   // Write words to this file
   WriteLn(myFile, '20 Sally');
   WriteLn(myFile, '9 John');
    WriteLn(myFile, '50 Jean');
     WriteLn(myFile, '34 Sam');

   // Close the file
   CloseFile(myFile);[COLOR="Lime"]}[/COLOR]

end;

procedure TfrmHigh.imgBackClick(Sender: TObject);
begin
frmHigh.Visible := False;
frmWelcome.Visible := True;
end;

end.
I hope this is not too much of a headach to anyone (My ignorance) but i hope this problem will be solved with great speed.:)

In Topic: Saving and reading a Text file

27 September 2008 - 04:20 AM

Ive sort of got the hang woth using a text file, but could anyone help me to add new data without deleting the old data and to edit the old data by removing what i dont need. I also have the problem that my changes to my text file arent saved when i exit my program and restart it.

I have a edit box for my new high score (for the persons name) and labels to display the names of people with older high scores. (These names i want to edit without rewriting them which rewrites the file and leaves the new high score out) I have a button to confirm the data in the editbox and write it to the file. This is what my code looks like:

unit assignment12_MDJ_u;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons;

type
  TfrmHigh = class(TForm)
    ListBox1: TListBox;
    bmbVeiw: TBitBtn;
    bmb: TBitBtn;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Edit1: TEdit;
    BitBtn1: TBitBtn;
    procedure FormShow(Sender: TObject);
    procedure bmbClick(Sender: TObject);
    procedure bmbVeiwClick(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmHigh: TfrmHigh;
     myfile : textfile;
implementation

uses assignment_MDJ_u;

{$R *.dfm}
procedure Write;
  var
    myfile : textfile;
  text : string;
begin

end;


procedure TfrmHigh.FormShow(Sender: TObject);
var
  text : string;
begin

end;

procedure TfrmHigh.bmbClick(Sender: TObject);
begin

  AssignFile(myFile, 'Test.txt');
  ReWrite(myFile);


  WriteLn(myFile, EDIT1.text);
  WriteLn(myFile, label1.caption);
  WriteLn(myFile, label2.caption);
  WriteLn(myFile, label3.caption);


  CloseFile(myFile);
end;

procedure TfrmHigh.bmbVeiwClick(Sender: TObject);
var
text : string;
begin
   Reset(myFile);

   while not Eof(myFile) do
   begin
     ReadLn(myFile, text);
     listbox1.Items.Add(text);
   end;

   CloseFile(myFile);

end;
end.

could anone tell me what i must add or change and under what sections in detail please.

I hope im not too much of a burden but my text books dont tell me how to do this thanks.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download