Einzelnen Beitrag anzeigen

Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#19

Re: Umwandlung charkombination nach integer

  Alt 2. Sep 2009, 21:16
Hi,

Hab nochwas:

Delphi-Quellcode:
// Speichert maximal 4 Buchstaben in einer Zahl (4 Byte)
function StrToCardinal(S: String): Cardinal;
begin
  Result := PCardinal(S)^;
end;

// Extrahiert den String aus dem Cardinal
function CardinalToStr(C: Cardinal): String;
begin
  SetLength(Result,4);
  Move(c,Result[1],4);
end;

// Anwendung:
var c: Cardinal;
    s: String;
begin
  S := 'Test';
  c := StrToCardinal(S);
  Caption := CardinalToStr(c);
end;
Gruß
Neutral General
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat