Solved

trying to do a simple division

Posted on 2002-03-07
12
196 Views
Last Modified: 2010-04-05
hi folks,
im trying the follow:
edit3.text := inttostr(strtoint(edit1.text) / strtoint(edit2.text));

where the value in edit2 is 20. when i compile this i get an error saying something like: theres no version for overloading 'inttostr' which can be done with the given arguments, any hints
0
Comment
Question by:ugross
  • 6
  • 3
  • 3
12 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6847338
try this

edit3.text := floattostr(strtoint(edit1.text) / strtoint(edit2.text));

0
 

Author Comment

by:ugross
ID: 6847376
when trying this i get a bde exception of the class edbengineerror, error during initialization (error#2501)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6847399
this may different things,

the bde error 2501 is definitiv not caused by the division,
except you modify with the result the bde alias

as stated in the other q, you can calculations do
with a calculated field in the oncalcevent of the underlying dataset.

but i guess you've first to solve your bde error,
maybe a wrong databasedriver in the alias

meikl ;-)
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 3

Accepted Solution

by:
Ronald Buster earned 100 total points
ID: 6847576
hi

try this

edit3.text := inttostr(strtoint(edit1.text) div strtoint(edit2.text));

Integers can works a bit different when dividing you have to use the keyword "div" instead of "/".

regards,

Cono
0
 

Author Comment

by:ugross
ID: 6847603
you made it, works now, thx
0
 

Author Comment

by:ugross
ID: 6847663
hi cono, short additional q
as already said your solution works but im only getting
full numbers eg. 4 where when i manually calculate this the exact result is 4.75, what do i have to change to get the exact result, thx
0
 
LVL 3

Expert Comment

by:Ronald Buster
ID: 6847716
try

this

edit3.text := floattostr(strtofloat(edit1.text) / strtofloat(edit2.text));

you have to make sure there are valid digits in the edit1 and edit2 control. And when using decimalseparator please
be sure to use a "." or "," depending on your decimalseparator variable.

Setting

decimalseparator := '.';

regards

Cono
0
 

Author Comment

by:ugross
ID: 6847735
hi i used this but got an error that string an dinteger r incompat.:
edit1.text := strtofloat(strtoint(edit1.text) div strtoint(edit2.text));
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6847910
ts ts ts

edit3.text := floattostr(strtoint(edit1.text) / strtoint(edit2.text));

hu a dejavu
0
 
LVL 3

Expert Comment

by:Ronald Buster
ID: 6847969
You must do this otherwise strtoint doesn't make it a float
you've got an error

do this

edit3.text := floattostr(strtofloat(edit1.text) / strtofloat(edit2.text));


edit1.text := '10'
edit2.text := '3'
edit3.text will contain the value '3.333333';

0
 

Author Comment

by:ugross
ID: 6849827
hi guys, sorry got the error that thi si not a valid
integer value, thx
0
 

Author Comment

by:ugross
ID: 6849833
sorry your answers were correct my fault, the error came from the next row of code which is:
dbedit1.Text := edit1.text; (for saving the value in the database)
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 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