Discussion:
Wanted: TEdit with thousands separator when typing/deleting/editing/backspacing
(too old to reply)
Skybuck Flying
2015-02-20 21:44:35 UTC
Permalink
Hello,

When user types numbers into TEdit the numbers should have thousands
separators like so:

1.000.000.000.000

When user deletes a zero anywhere it should look as follows:

100.000.000.000

The thousands separators need to be displayed while
typing/deleting/editing/backspacing etc.

I am looking for a component which already does this and it has to be free
=D

Components already tried and are not suited:

TEdit
TLabeledEdit
TMaskEdit
TSpinEdit
TJvValidateEdit
TIntEdit
TFloatEdit

Bye,
Skybuck.
Skybuck Flying
2015-02-20 22:15:39 UTC
Permalink
Ok,

I found a component which can do what I want for now... it's a bit older but
it will probably do for now:

Here is a hint:

TAdvEdit

By setting it to money it will do the typing and formatting thing... and
does delete/backspace and such as well.

Bye,
Skybuck.
Skybuck Flying
2015-02-20 22:20:51 UTC
Permalink
There is a little problem though.

It doesn't handle int64 return values yet...

Hmmm... trying to update it.

If that fails I could maybe use double... but would prefer int64 for more
precision.

Bye,
Skybuck.
Skybuck Flying
2015-02-20 22:24:41 UTC
Permalink
Problem seems to be with Delphi's val routine.

It has no 64 bit implementation ?

Bye,
Skybuck.
Skybuck Flying
2015-02-20 22:29:11 UTC
Permalink
Oh never mind, the documentation is old...

According to stack overflow val does work for int64.

I changed code as follows

from:

function ValStr(s: string): int64;
var
err: int65;
begin
val(s, result, err);
end;

to:

function ValStr(s: string): int64;
var
err: integer;
begin
val(s, result, err);
end;

Fortunately I noticed the problem.

Apperently err returns some error code in err... and integer is enough for
it, it is actually required... otherwise it can't find a proper overloaded
version.

Bye,
Skybuck.
Skybuck Flying
2015-02-20 22:47:09 UTC
Permalink
Hmm

9223372036854775807
9223372036854775808 is a corner case... might turn negative.

Also pasting not supported... not sure yet why.

I consider pasting pretty damn important...

If it can't work with pasting I may have to ditch this component.

Bye,
Skybuck.
Skybuck Flying
2015-02-20 22:50:28 UTC
Permalink
It seems to be some whacky unicode issue.

The number from calculator is shown as chinese text inside Delphi... hmmm..

Bye,
Skybuck.
Skybuck Flying
2015-02-20 23:04:02 UTC
Permalink
Ok defining Unicode and adding some Skybuck magic it's working for now.

Wieee =D

Bye,
Skybuck.

Loading...