I Need Help....

I have Delphi 3, and I am a newbie.  The thing I want to know is, why doesn't this program work.  It is supposed to calculate a money value.  When I press F9 to run the program, it gives me this error:

Error in module Unit1: 'END.' missing at end of module.

Here is the program:

procedure TForm1.Button1Click(Sender: TObject);
var
subtot, vat: double;
errcode : integer;
begin
Val(Edit1.Text, subtot, errcode );
if errcode <> 0 then
ShowMessage('You must enter a number!')
else
begin
vat := subtot * 0.175;
Caption := 'VAT = $' + FloatToStr(vat);
Edit2.Text := '$'+ FloatToStr(subtot + vat);
end;
end.

So, what am I doing wrong here?...or if I'm not doing anything wrong; why doesn't it want to work?  Please help.
CyberMageAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CyberMageAuthor Commented:
Edited text of question.
0
intheCommented:
hi
you a re missing a end;

procedure TForm1.Button1Click(Sender: TObject);
var
subtot, vat: double;
errcode : integer;
begin
Val(Edit1.Text, subtot, errcode );
if errcode <> 0 then
ShowMessage('You must enter a number!')
else
begin {<--another begin here so needs a end; }
vat := subtot * 0.175;
Caption := 'VAT = $' + FloatToStr(vat);
Edit2.Text := '$'+ FloatToStr(subtot + vat);
end;
end; {<--- added a end here and it works}
end.

Regards Barry
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CyberMageAuthor Commented:
But, why does it need the extra end; for...that is what I don't seem to understand?!
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

edeyCommented:
you might also note that developing a clear, consistent indentation style is important part of writing maintainable (and sharable & debugable... :) code, perhaps something like so:

procedure TForm1.Button1Click(Sender: TObject);
var
   subtot, vat: double;
   errcode : integer;
begin
     Val(Edit1.Text, subtot, errcode );
     if errcode <> 0 then
       ShowMessage('You must enter a number!')
     else
     begin {<--another begin here so needs a end; }
          vat := subtot * 0.175;
          Caption := 'VAT = $' + FloatToStr(vat);
          Edit2.Text := '$'+ FloatToStr(subtot + vat);
     end;
end; {<--- added a end here and it works}


end.



GL
Mike
0
intheCommented:
hi
you ask why you need an extra end;
well every begin needs a end; else the compiler wont know where the procedure
finishes.


a procedure()
begin           < begin 1
 dosomething()  
 elseif  
  something then
   begin       < begin 2
    stuff;
   end;        < end 2
 end;          <end 1

end.  <this means end of whole unit


if you are new to delphi maybe its best to get a book that explains the syntax so you understand it better.most delphi books cover the basic syntax
(did you not get some books in the box when you bought delphi called "object pascal language guide ?))
0
CyberMageAuthor Commented:
No.  Because I got Delphi 3 for free, from PC Plus magazine (http://www.pcplus.co.uk/).  But, it came with a years tutorial in PDF format.  But, I may still buy a book on it.
0
intheCommented:
:-))
the best mag for software (i also subscribe).
loads of delphi books on amazom at good prices also.
happy learning ;-)
0
CyberMageAuthor Commented:
I cannot buy on Amazon, I don't have a credit card...that is what I hate about e-commerce; they expect everyone to have a credit card.  :(
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.