Solved

why does not this work

Posted on 2007-03-26
3
181 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dev Express grid collapse 2 47
Dynamically Created Query 3 70
Delphi and Access based Enumeration 9 78
Add New Database Table in database file using delphi 3 29
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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