#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    9
    Rep Power
    0

    Program update problem


    I have program that compares your answers to those in a database.
    Everything works except that every time you launch the program the first time it will not update the score (correct or wrong), the VAR gets updated but not the label that it is connected to.
    When you answer the next Q it works 100%, just the first time it will not update the label.
    I have tried almost everything to get it working !!!

    ADOTable1.first;
    while not ADOTable1.EoF do
    begin
    if ID1int = ADOTable1['ID']
    then
    begin
    if Edit2.Text = ADOTable1['English'] then
    begin
    correctint := correctint + 1
    end
    else
    wrongint := wrongint +1;
    exit;
    end;
    Label11.Caption := IntToStr(correctint);
    Label10.Caption := IntToStr(wrongint);
    Label2.Caption := IntToStr(helpint) ;
    form2.Update;
    form2.Refresh;
    Label11.Refresh;
    Label10.Refresh;
    Label2.Refresh;
    ADOTable1.Next;
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    350
    Rep Power
    7
    A few items that may help you:

    Code:
    //did you initialize correctint and wrongint
    correctint := 0;
    wrongint := 0;
    ADOTable1.first;
    while not ADOTable1.EoF do
    begin
       if ID1int = ADOTable1['ID'] then
       begin
          if Edit2.Text = ADOTable1['English'] then
          begin
             correctint := correctint + 1
          end
          else
             wrongint := wrongint +1;
          exit;//<-- Why are you exiting?
          //as coded this will always exit 
          //if ID1int = ADOTable1['ID']
          //if you want to only exit if incorrect answer then both 
          //wrongint := wrongint + 1; and exit; needs to be
          //enclosed in Begin..End blocks
       end;
       Label11.Caption := IntToStr(correctint);
       Label10.Caption := IntToStr(wrongint);
       Label2.Caption := IntToStr(helpint) ;
       form2.Update;//not needed
       form2.Refresh;//not needed
       Label11.Refresh;//not needed
       Label10.Refresh;//not needed
       Label2.Refresh;//not needed
       ADOTable1.Next;
    end;//need end to the while loop

    Comments on this post

    • clivew agrees : Hard to know if you are really helping or spinning your wheels with an incomplete snippet of a method.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    9
    Rep Power
    0
    It tried the best i could but now it just keeps adding it to the wrong integer.
    (new edited code)

    ADOTable1.first;
    while not ADOTable1.EoF do
    begin
    if ID1int = ADOTable1['ID']
    then
    begin
    if Edit2.Text = ADOTable1['English'] then
    begin
    correctint := correctint + 1
    end
    else
    begin
    wrongint := wrongint +1;
    exit;
    end;
    end;
    Label11.Caption := IntToStr(correctint);
    Label10.Caption := IntToStr(wrongint);
    Label2.Caption := IntToStr(helpint) ;
    //form2.Update;
    //form2.Refresh;
    //Label11.Refresh;
    //Label10.Refresh;
    //Label2.Refresh;
    ADOTable1.Next;
    end;
    end;
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    350
    Rep Power
    7
    I'm assuming that your procedure is attempting to count the number of correctly and incorrectly answered questions. Given that, I still do not understand why you are exiting when you find an incorrectly answered question.

    The purpose of exit is to abruptly exit from a function or procedure.

    When you exit, your label captions will not be updated.

    Also, can you please describe your ADO data source? You are comparing two columns in two different if statements, I'm not sure I understand.

IMN logo majestic logo threadwatch logo seochat tools logo