Wednesday, 15 August 2012

Delphi 7 Sum of two numbers with decimals -



Delphi 7 Sum of two numbers with decimals -

beginner here :)

i trying create delphi application requires user input , adds , subtracts variables.

i succeeded in creating application , works fine except:

cannot find proper way deal numbers decimals.

example:

a,b,c,d,e,f: string; a1,b1,c1,d1,e1,f1: integer:

i utilize inputbox user inputs. store inputs in string variables. convert string variable integer a1 := strtoint(a); @ end, want to: a1+b1-c1-d1-e1-f1 end works if input integer. problem arises if user come in number decimals.

i have searched on place not find reply problem.(or did not understood)

anyone can please point me in right direction?

thank you.

you trying convert string floating point value.

first of need alter integer variables of type double. allow store values not integers.

secondly need different function perform conversion. should utilize trystrtofloat. attempts convert string floating point. if conversion succeeds function returns true, otherwise returns false. example:

var str: string; value: double; .... if not trystrtofloat(str, value) begin // handle error in appropriate way end; // value

delphi delphi-7

No comments:

Post a Comment