BrianG14
asked on
Variable
I am new to delphi, infact at the time I posted this message I have only had it for about 20 minutes. I downloaded the trial version. I am very good with Basic. Okay, I have a progress bar how do I make it add 1 to a so if any one knows basic, below is an example of what I want to do in delphi.
do
a$ = a$ + 1
loop until a$ = 100
and I want a$ to be the postition of the progress bar...so, I want it to add 1 to the progress bar until it reaches 100.
progressbar1.min := 0;
progressbar1.max := 100;
progressbar1.Smooth := true;
progressbar1.position := 1;
do
a$ = a$ + 1
loop until a$ = 100
and I want a$ to be the postition of the progress bar...so, I want it to add 1 to the progress bar until it reaches 100.
progressbar1.min := 0;
progressbar1.max := 100;
progressbar1.Smooth := true;
progressbar1.position := 1;
ASKER
okay, this is what my code for whent he button is pressed looks like
procedure TForm1.Button1Click(Sender : TObject);
begin
progressbar1.min := 0;
progressbar1.max := 100;
progressbar1.smooth := true;
var
i : integer;
begin
for i := 0 to 100 do
progressbar1.position := progressbar1.position +1;
end;
end.
but I get errors...HELP!
procedure TForm1.Button1Click(Sender
begin
progressbar1.min := 0;
progressbar1.max := 100;
progressbar1.smooth := true;
var
i : integer;
begin
for i := 0 to 100 do
progressbar1.position := progressbar1.position +1;
end;
end.
but I get errors...HELP!
ASKER
okay, this is what my code for whent he button is pressed looks like
procedure TForm1.Button1Click(Sender : TObject);
begin
progressbar1.min := 0;
progressbar1.max := 100;
progressbar1.smooth := true;
var
i : integer;
begin
for i := 0 to 100 do
progressbar1.position := progressbar1.position +1;
end;
end.
but I get errors...HELP!
procedure TForm1.Button1Click(Sender
begin
progressbar1.min := 0;
progressbar1.max := 100;
progressbar1.smooth := true;
var
i : integer;
begin
for i := 0 to 100 do
progressbar1.position := progressbar1.position +1;
end;
end.
but I get errors...HELP!
hi,
variables (var) cannot go inside a begin end statement:they either go where i have put it in the code below or as a global var which can be used in other events as well
see at the top of your unit you have
"
var
form1 : tform1;
//you can add more variables here to look like:
var
form1 : tform1;
i : integer;
s : string;
sl : tstringlist;
etc..
they would be global vars
whereas the var in the procedure below can only be used in that procedure.
i suggest getting some books for delphi.
it is not hard to learn but the books help also se the help files as they have many examples of using the components.
procedure TForm1.Button3Click(Sender : TObject);
var
i : integer;
begin
progressbar1.min := 0;
progressbar1.max := 100;
progressbar1.smooth := true;
for i := 0 to 100 do
progressbar1.position := progressbar1.position +1;
end;
variables (var) cannot go inside a begin end statement:they either go where i have put it in the code below or as a global var which can be used in other events as well
see at the top of your unit you have
"
var
form1 : tform1;
//you can add more variables here to look like:
var
form1 : tform1;
i : integer;
s : string;
sl : tstringlist;
etc..
they would be global vars
whereas the var in the procedure below can only be used in that procedure.
i suggest getting some books for delphi.
it is not hard to learn but the books help also se the help files as they have many examples of using the components.
procedure TForm1.Button3Click(Sender
var
i : integer;
begin
progressbar1.min := 0;
progressbar1.max := 100;
progressbar1.smooth := true;
for i := 0 to 100 do
progressbar1.position := progressbar1.position +1;
end;
ASKER
oh, okay thanks, now can u tell me if there is any way I can make the program pause...so like evertime it adds 1 to the progress bar it sleeps for .5 seconds...or something like that.
ASKER
also, how can I make it do multiple tasks while its looping...I want it to add up in the progressbar like it does and add 1 to a label as well...THANKS!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
okay, thanks for your help...and as to your advice on getting books...whenever I read books they confuse me. I seem to learn programming languages better by just trying code. Thanks!
you can use a loop like this:
var
i : integer;
begin
for i := 0 to 100 do
progressbar1.position := progressbar1.position +1;
Regards Barry