Delphipage - la reference en Delphi
Accueil - Astuces - Composants - Programmes - Tutoriaux - Livres - Liens
 Sources
- Astuces
- Composants
- Programmes
- Tutoriaux
 Rechercher
- Delphipage
- Ngscan
 Ressources
- Lexique Delphi
- Livres
- News
- Patchs Delphi
 Liens
- Borland France
- CodeGear
- Les meilleurs sites


Astuces - Divers - Convertir un nombre decimal en une base X en Delphi

Ajouter un composant TButton et TLabel.

Function DecToBasex(Decimal:LongInt;const Base:Byte):string;
const Symboles: String[16] = '0123456789ABCDEF';
Var nom: String;
a: Byte;
begin
nom:= '';
repeat a:=Decimal mod Base;
nom:=Symboles[a+1]+nom;
Decimal := Decimal div Base;
until(Decimal=0);
Result := nom;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.caption:=DecToBasex(12,16);
//transforme le chiffre 12 en decimal en base 16
//le resultat est C
end;


Tous droits réservés - Contacts
Haut de la page