Autor Beitrag
Hammel
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Mo 28.08.06 00:31 
Hi, ich wollte fragen, wie ich einem Integer < 10 Wert eine 0 voranstellen kann?
Muss z.Z. auftraglich mich an delphi hernatatsen und als gelernter phpler wollt ich des Ganze mit ner if abfrage lösen, jedoch suche ich vergeblich den benötigten Operator zum verbinden der 0 mit der Variable.
Wäre nett, wenn jemand helfen könnte ;)


Zuletzt bearbeitet von Hammel am Mo 28.08.06 00:50, insgesamt 1-mal bearbeitet
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 28.08.06 00:36 
Moin und :welcome: im Forum!

Probier das mal so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
  procedure ShowVar(const IntVar: Integer);
  begin
    if (IntVar < 10) then
      ShowMessage('0'+IntToStr(IntVar)
    else
      ShowMessage(IntToStr(IntVar);
  end;

begin
  ShowVar(3);
  ShowVar(17);

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Hammel Threadstarter
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Mo 28.08.06 00:48 
user profile iconNarses hat folgendes geschrieben:
Moin und :welcome: im Forum!

Probier das mal so:

cu
Narses


danke, für die schnelle Hilfe!
Da hatte ich doch glatt vergessen den Integer vorher in einen String umzuwandeln, bevor ich ihn in einer Editbox ausgebe :oops:
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 28.08.06 04:45 
Alternativ sollte das auch so gehen: ShowMessage(Format('%.2d', [IntegerWert])); ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.