Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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.exeThe 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

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

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

![]() |
![]() |
![]() |

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