R
redweek
Unregistered / Unconfirmed
GUEST, unregistred user!
下面的Function总是防回0,为什么?<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> Edit1: TEdit;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> Function IntToBCD(TT:integer;hh:array of byte):integer;<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>FUnction TForm1.IntToBCD(TT:integer;hh:array of byte):integer;<br> var<br> STemp:array[0..3]of byte;<br> // hh:array[0..1]of byte;<br> i:integer;<br>begin<br> for I:=0 to 3 do<br> STemp:=0;<br> STemp[0]:=trunc(tt/1000);<br> STemp[1]:=trunc((TT-STemp[0]*10000)/100);<br> STemp[2]:=Trunc((TT-STemp[0]*1000-STemp[1]*100)/10);<br> STemp[3]:=TT mod 10 ;<br> hh[0]:=STemp[0]*16+STemp[1];<br> hh[1]:=STemp[2]*16+STemp[3];<br><br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br> var<br> dd:array[0..1] of byte;<br>begin<br> IntToBCD(1234,dd);<br> edit1.text:=inttostr(dd[0])+inttostr(dd[1]);<br>end;<br><br>end.<br>