Computing.Net > Forums > Programming > Pascal (Delphi 5) Question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Pascal (Delphi 5) Question

Reply to Message Icon

Name: Daniel A-S (by Daniel Ashley-Smith)
Date: November 26, 2005 at 09:20:14 Pacific
OS: XP
CPU/Ram: 2.66 GHz / 1024 DDR
Comment:

Ok I've just started learning pascal, so bare with me. I'm basically trying to play around with certain functions, see what works, what doesn't e.t.c. to get to know the language better.

I made this simple program:
http://homepage.ntlworld.com/bas/project4.exe

The problem I'm having is that when you leave the box(es) empty it comes up with an error message. Obviously because it can't add two *nothings*.

Any suggestions as to what program line I should put in? Something along an IF THEN statement?

Thanks for any help.

Daniel Ashley-Smith
London, U.K



Sponsored Link
Ads by Google

Response Number 1
Name: geolew
Date: November 26, 2005 at 18:39:59 Pacific
Reply:

as a quickie try.

if <fieldname>.text = '' then
begin
writeln('Dang Nothing entered');
end
else
begin
{ we have something so lets work with it}
end;

Ps look up
Try
Except
Finally
end;

George


0

Response Number 2
Name: Daniel A-S (by Daniel Ashley-Smith)
Date: November 28, 2005 at 06:19:57 Pacific
Reply:

Worked perfectly, with a few tiny adjustments to fit the program.
Thanks a lot.

The only other thing is.. I now need it to put an IF on TWO values.

At the moment I have this:

procedure TForm1.Button2Click(Sender: TObject);
begin
if
Edit1.text = '' and Edit2.text = ''
then
begin
Edit3.text := '0';
end
else
Edit3.text := FloatToStr(StrToFloat(Edit1.text) + StrToFloat(Edit2.text));
end;

The error is in the "Edit1.text = '' and Edit2.text = ''" line. It works with just the edit1 box but when I add "and edit2.text" it won't compile.

Any ideas on how I'm supposed to write this?
Thanks.

Daniel Ashley-Smith
London, U.K


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Pascal (Delphi 5) Question

Delphi 5 Question www.computing.net/answers/programming/delphi-5-question/15230.html

delphi 5 www.computing.net/answers/programming/delphi-5/7791.html

.Useserial port (RS232) with Delphi 5.0 www.computing.net/answers/programming/useserial-port-rs232-with-delphi-50/803.html