vendredi 5 novembre 2021

Condition always evaluates to true regardless of actual values

I have created an if statement that I want to output a message using the showmessage Delphi function and I have set it to display said message when an entered code matches a generated code however it still outputs the "well done!" message even when blatantly wrong.

Button code:

procedure TfrmCAPTCHA.btnCheckClick(Sender: TObject);

 var
 sCode, sAnswer : string;
 bRightAnswer, bWrongAnswer : boolean;

begin

{button to verify input}

  sANswer := trim(edtAnswer.Text);
  sCode := edtCaptchaCode.Text;

  bRightAnswer := (sAnswer = sCode);
  bRightAnswer := True;

  bWrongAnswer := (sAnswer <> sCode);
  bWrongAnswer := False;

    if bRightAnswer then  

      begin

        btnCAPTCHAContinue.Show;
        Showmessage('Nicely Done, seems you''''re all set to go!' + #13 +
                    'Press the continue button to collect your codes young wizzling');
      end
      else begin

        edtCAPTCHACode.clear;
        edtAnswer.clear;
        btnCAPTCHAContinue.Hide;
        Showmessage( 'That seems to be the wrong answer, please try again');

      end;

end;

Aucun commentaire:

Enregistrer un commentaire