21-07-2011, 06:44 PM
السلام عليكم
انظر هذا الكود أخي
بالتوفيق
انظر هذا الكود أخي
كود :
implementation
type
TCharSet = set of Char;كود :
function StripNonConforming( const S: string;
const ValidChars: TCharSet): string;
var
DestI: Integer;
SourceI: Integer;
begin
SetLength(Result, Length(S));
DestI := 0;
for SourceI := 1 to Length(S) do
if S[SourceI] in ValidChars then
begin
Inc(DestI);
Result[DestI] := S[SourceI]
end;
SetLength(Result, DestI)
end;
function StripNonNumeric( const S: string): string;
begin
Result := StripNonConforming(S, ['0'..'9'])
end;كود :
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.Text:=StripNonNumeric(Label1.Caption);
end;

