Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

why does not this work

Posted on 2007-03-26
3
Medium Priority
?
186 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 200 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

715 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