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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Heeeeeelp(Use Step or Run)

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I get the "Use Step or Run" dialog when I try to load the following up(help):

unit TMA26u1;

interface

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

type
TTMA26f1 = class(TForm)
lHello: TLabel;
lNum1: TLabel;
lNum2: TLabel;
lRemark: TLabel;
eAns: TEdit;
procedure eAnsChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
TMA26f1: TTMA26f1;
sAns:string;

implementation

{$R *.dfm}
procedure PickProb;
begin
TMA26f1.lNum1.caption:=IntToStr(random(9));
TMA26f1.lNum2.caption:=IntToStr(random(9));
sAns:=IntToStr(StrToInt(TMA26f1.lNum1.caption)+StrToInt(TMA26f1.lNum2.caption));


end;
procedure TTMA26f1.eAnsChange(Sender: TObject);
begin
if eAns.text=sAns then begin
lRemark.caption:='Yes';
end (*no ; here*)
else begin
lRemark.caption:='I don''t think so';
end;

end;
(*of TTMA23f1.eAnsChange*)

procedure TTMA26f1.FormCreate(Sender: TObject);
begin
Randomize;
PickProb;
end;


begin
PickProb;
end.
 
Procedure 'PickProb' modifies some
properties of TMA26f1, but it is
executed BEFORE the form is created...
Remove the call to PickProb from last
lines.
 
Hi Karxarias

Try using 'FormActivate' instead of 'FormCreate' if you want your program to do it's thing stright away. rather than using a Button method.

You may still have a problem if you want your form to maximise. Get around this by putting your procedure call in a timer event, initalise the timer to say 1 second and enable the timer in formactivate, that will give the form plenty of time to set itself up.
Steve.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top