Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

data entry

Status
Not open for further replies.

rogerte

Programmer
Nov 9, 2001
164
GB
I have to convert a legacy clipper app to delphi, and it involves a lot of entries in a format nn.nn where nn.nn is a number between 0 and 10

In the clipper app (using @ SAY Gets) the picture clause "99.99" allows the user to enter (say):
5
5.0
6.15
.6
and all are accepted and displayed correctly as the data enters.

Also by defaulting the vaues to 0 the "mask" displays as "0.00".

The commissioners of this project have decreed that the edits must behave exactly like those in the Clipper app.

I have tried looking at various maskedits, but none seem to mimic this behaviour.

Does anyone know of how to do this in Delphi (4 or 7)?

Many thanks

Roger
 
Opp

Thanks, but that has a problem.

If you enter 5.67 it shows as 50.67, even though the text property records the value correctly.

This is not acceptable to the management users, as the data entry people are very fast and usually only glance at the screens rarely. They need to see on screen exactly what they think they have entered.

I have tried to refresh the value using the onchange and/or onexit events, but I havn't managed to do so.

Roger
 
Ahh.. In that case you may want to do away with the Editmask altogether and use code to validate and/or format the input. For example.. On Exit handler may look like..

procedure TForm1.Edit1Exit(Sender: TObject);
var
x : real;
begin

try
x := StrToFloat(Edit1.Text);
// If users enter non-valid floating
// Point value - will trigger
//exception
Except
on E:Exception do
begin
showmessage('Invalid Input : ' + E.Message);
Edit1.SetFocus;
end;
end;

end;

You can put additional coding in there to maybe do other things (like format the input to '00.00' if the user enters '0') but I will leave that to your imagination.
Hope this helps..

Opp.
 
Suggestion 1.

Woll to Woll's Infopower has very good masks, much better than Delphi's.

Suggestion 2.

Use the OnKeyPress and OnKeyDown events to handle every keystroke into a TEdit. Then use properties text, selstart, sellength and seltext to gain full control over keystrokes and what is displayed. It sounds complex but, when you get down to it it does not take very long.

Have fun
Simon

 
Use orpheus componets, it's free and very good and
with it you can find better edit/combo with better
ways to mask things.

look for it in

it's free !!!

Griffe
 
Thanks to everyone.

Sorry have not answered before, but have been away for a few days.

I finally sorted it using the "onChange" event and the "OnExit" event.

I will try the various suggestions (e.g. Orpheus).

Roger
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top