Reputation: 1188
I was wondering if there is a component like the 'edit', but just for numbers so I can use the .value
function in my code.
My textbook says I must make a program, that when the user enters a number and clicks the execute button, the results of the functions must be determined.
The functions are: Trunc, round, frac, sqr and sqrt.
I have to enter the value into, what looks like an 'edit', but whenever I use the .value
in my code, it gives me an error saying :Undeclared identifier: 'value'
. Although it works when I use a 'SpinEdit'.
Forgive me for being really thick, I do have a severe chest and sinus infection with a fairly bad fever, so my mind is somewhere else at the moment.
Thanks!
Oh, and by the way, I have also used the 'MaskEdit' component but it still gives me the same error
Upvotes: 1
Views: 977
Reputation: 2121
Well, since you asked if there is an edit like component for that, I use TMS AdvEdit. It does a very decent job handling integers and floats. If you can afford it, it's really useful.
It has .FloatValue
and .IntValue
properties for reading and writing the value, and an EditType
that specifies what kind of input is accepted.
Upvotes: 0
Reputation: 612993
For an edit control there is no property named Value
, which is what the compiler is telling your. For an edit control the property you need is Text
. That's a string
containing the contents of the edit control. You'll need to use StrToFloat
or TryStrToFloat
to convert to a real type.
You can use a masked edit if you like, and validate the input on entry. The TMaskEdit
control derives from TCustomEdit
, and again the property used for accessing its content is Text
and of type string
.
Personally I don't like that because I don't think it gives the clearest feedback to users. It's also hard to write a mask for a general floating point value. Myself, I would validate at the point where the program needs to convert from string to real.
Upvotes: 1