Solved

why does not this work

Posted on 2007-03-26
3
176 Views
Last Modified: 2010-04-05
procedure TPostavke.SpeedButton1Click(Sender: TObject);
var a,b,c: integer;
begin
if TryStrToInt(dbedit8.text,a) and TryStrToInt(edit40.Text,b) and TryStrToInt(edit50.text,c) then
  c:= a - b;

end;
0
Comment
Question by:Vrtnar
  • 3
3 Comments
 
LVL 28

Expert Comment

by:TName
ID: 18792794
It should work, but are you sure you want to test if c is an integer...?
a and be should be integers, c could be empty, you overwrite it's value anyway,


procedure TPostavke.SpeedButton1Click(Sender: TObject);
var a,b,c: integer;
begin
if TryStrToInt(dbedit8.text,a) and TryStrToInt(edit40.Text,b) then
  c:= a - b;
 
ShowMessage(IntToStr(c));
end;
0
 
LVL 28

Expert Comment

by:TName
ID: 18792812
>if c is an integer
I mean if edit50.Text is an integer (and dbedit8.Text and edit40.Text...)    ;)
0
 
LVL 28

Accepted Solution

by:
TName earned 50 total points
ID: 18794067
Or du you want to display the result in edit50?
Then you should try something like:

procedure TPostavke.SpeedButton1Click(Sender: TObject);
var a,b,c: integer;
begin
  if TryStrToInt(dbedit8.text,a) and TryStrToInt(edit40.Text,b) then begin
    c:= a - b;
    edit50.Text:=IntToStr(c);
  end;
end;
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

20 Experts available now in Live!

Get 1:1 Help Now