• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 251
  • Last Modified:

Beginner's math problem with Delphi 7

Just a simple, I assume, task I need help with.

I need to do some multiplication using 1 decimal, the result should be rounded(no decimals).

Pasted the code below which gives me the error 2,5 is not a valid integer value.
for x :=1 to (strtoint(HOff2.Caption)) * strtoint(floattostr(2.5)) do begin

Open in new window

  • 2
1 Solution
the floattostr(2.5) was producing a '2.5'  so if you round it first it'll work:

for x :=1 to (strtoint(HOff2.Caption)) * strtoint(floattostr(round(2.5))) do begin

to be safe, round them both first:

for x :=1 to (strtoint(round(HOff2.Caption))) * strtoint(floattostr(round(2.5))) do begin

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

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