پارس نت گلستان



باید در uses از StrUtils,math استفاده شود



function Bet(S: string; Thousands: Boolean;Sender: TObject): string;
var
I, MaxSym, MinSym, Group: Integer;
IsSign: Boolean;
begin
for I :=1 to Trunc(Length(S)/3) do
Delete(S,Pos(ThousandSeparator,S),1);
Result := '';
MaxSym := Length(S);
IsSign := (MaxSym > 0) and (AnsiChar(S[1]) in ['-', '+']);
if IsSign then MinSym := 2
else MinSym := 1;
I := Pos(DecimalSeparator, S);
if I > 0 then MaxSym := I - 1;
I := Pos('E', UpperCase(S));
if I > 0 then MaxSym := Min(I - 1, MaxSym);
Result := Copy(S, MaxSym + 1, MaxInt);
Group := 0;
for I := MaxSym downto MinSym do
begin
Result := S[i] + Result;
Inc(Group);
if (Group = 3) and Thousands and (I > MinSym) then
begin
Group := 0;
Result := ThousandSeparator + Result;
end;
end;
if IsSign then Result := S[1] + Result;
if (Sender is TEdit) then
TEdit(sender).Perform(WM_KeyDown,VK_End,0)
end;
///////////////////
procedure TForm1.Edit1Change(Sender: TObject);
begin
Edit1.Text:=bet(Edit1.Text,true,Sender);
end;


آخرین ارسال ها

آخرین وبلاگ ها

آخرین جستجو ها