[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 205
  • Last Modified:

trying to do a simple division

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
ugross
Asked:
ugross
  • 6
  • 3
  • 3
1 Solution
 
kretzschmarCommented:
try this

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

0
 
ugrossAuthor Commented:
when trying this i get a bde exception of the class edbengineerror, error during initialization (error#2501)
0
 
kretzschmarCommented:
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
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Ronald BusterOwnerCommented:
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
 
ugrossAuthor Commented:
you made it, works now, thx
0
 
ugrossAuthor Commented:
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
 
Ronald BusterOwnerCommented:
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
 
ugrossAuthor Commented:
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
 
kretzschmarCommented:
ts ts ts

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

hu a dejavu
0
 
Ronald BusterOwnerCommented:
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
 
ugrossAuthor Commented:
hi guys, sorry got the error that thi si not a valid
integer value, thx
0
 
ugrossAuthor Commented:
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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 6
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now