Solved

why does not this work

Posted on 2007-03-26
3
183 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

729 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