Solved

Variable

Posted on 2000-03-19
8
127 Views
Last Modified: 2010-04-04
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;
0
Comment
Question by:BrianG14
  • 5
  • 3
8 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 2634234
hi,
you can use a loop like this:

var
i : integer;
begin
for i := 0 to 100 do
progressbar1.position := progressbar1.position +1;

Regards Barry
0
 

Author Comment

by:BrianG14
ID: 2634251
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!
0
 

Author Comment

by:BrianG14
ID: 2634254
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!
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 17

Expert Comment

by:inthe
ID: 2634269
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;
0
 

Author Comment

by:BrianG14
ID: 2634276
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.
0
 

Author Comment

by:BrianG14
ID: 2634286
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!
0
 
LVL 17

Accepted Solution

by:
inthe earned 10 total points
ID: 2634321
procedure TForm1.Button3Click(Sender: TObject);
var
i : integer;
begin
progressbar1.min := 0;
progressbar1.max := 100;
progressbar1.smooth := true;
for i := 0 to 100 do

 begin  <--added this

progressbar1.position := progressbar1.position +1;
sleep(milli) //type some time in millisecs here
label1.caption := progressbar1.position + '%';
end; <--added this

end;
0
 

Author Comment

by:BrianG14
ID: 2634335
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!
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Internet Explorer View Settings Question 15 111
Delphi selector screen 2 78
SUM 2 INTEGER ARRAYS INTO 1 10 100
Firemonkey DbLookupComboBox equivalent ? 2 47
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now