سلام
یه کامپوننت برای این که فقط اعداد رو بشه توش وارد کرد وجود داره اما قابلیت این که اونارو 3 رقم 3رقم جدا کنه نداره. با یکم دستکاری سعی کردم اونو به این شکل در بیارم
unit CurrencyEdit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TCurrencyEdit = class(TEdit)
private
{ Private declarations }
function getvalue:Extended;
procedure setvalue(NewVal:Extended);
protected
{ Protected declarations }
procedure KeyPress(var Key: Char); override;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
published
{ Published declarations }
property Value: Extended read GetValue write SetValue;
property Anchors;
property AutoSelect;
property AutoSize;
property BiDiMode;
property BorderStyle;
property CharCase;
property Color;
property Constraints;
property Ctl3D;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font;
property HideSelection;
property ImeMode;
property ImeName;
property MaxLength;
property OEMConvert;
property ParentBiDiMode;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PasswordChar;
property PopupMenu;
property ReadOnly;
property ShowHint;
property TabOrder;
property TabStop;
property Text;
property Visible;
property OnChange;
property OnClick;
property OnContextPopup;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnStartDock;
property OnStartDrag;
end;
procedure Register;
implementation
var tempvalue: Extended;
procedure Register;
begin
RegisterComponents('Samples', [TCurrencyEdit]);
end;
{***************** Methods *******************}
constructor TCurrencyEdit.create(Aowner:TComponent);
begin
inherited ;
text:='0'+decimalseparator+'0';
tempvalue:=0;
end;
function TCurrencyEdit.getvalue:Extended;
begin
try
{if text='' then text:='0';}
if text='' then result:=0
else result:=tempvalue;
except
on E: EConvertError do
begin
ShowMessage(E.ClassName + #13 + E.Message);
result:=0;
end;
end;
end;
procedure TCurrencyEdit.Setvalue(Newval:extended);
begin
tempvalue:=newval;
Text:=CurrToStrf(tempvalue,ffCurrency,0);
end;
procedure TCurrencyEdit.KeyPress(var Key: Char);
begin
if not (Key in ['+', '-', DecimalSeparator, '0'..'9', #0..#31] )
or ((key = decimalseparator) and (pos(decimalseparator,text)>0) )
then
begin
Key := #0;
MessageBeep(MB_ICONEXCLAMATION);
end
else inherited KeyPress(Key);
end;
end.
اما نیجه مورد نظر رو نمی ده. لطفا راهنمایی کنید.
با تشکر