Beginner's math problem with Delphi 7

Posted on 2009-04-28
Last Modified: 2012-05-06
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

Question by:MerlaP83
    LVL 6

    Accepted 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

    LVL 6

    Expert Comment

    to be safe, round them both first:

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

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
    Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    This video discusses moving either the default database or any database to a new volume.

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now