S sanqou Unregistered / Unconfirmed GUEST, unregistred user! 2006-08-18 #1 如题。我是初学者,查阅了一下以前的帖子。我想分别转换,即:<br>2006--二OO六年;8月--八月...18---十八日<br>不知道,大家在实际中是如何做的?
D dey-999 Unregistered / Unconfirmed GUEST, unregistred user! 2006-08-18 #2 年:<br>function tochina(num:integer) char;<br>begin<br> case num of<br> 0:<br>result:='0';<br> 1:<br>result:='一';<br> 2:<br>result:='二';<br> 3:<br>result:='三';<br> 4:<br>result:='四';<br> 5:<br>result:='五';<br> 6:<br>result:='六';<br> 7:<br>result:='七';<br> 8:<br>result:='八';<br> 9:<br>result:='九';<br> end;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var ss,s:string;<br> i,iValue:integer;<br>begin<br> iValue:=2006;s:='';<br> for i:=1 to length(inttostr(iValue)) do begin<br> ss:=inttostr(iValue);<br> s:=s+tochina(strtoint(ss));<br> end;<br> showmessage(s);<br>end;<br>月、日:<br>procedure TForm1.Button2Click(Sender: TObject);<br>var ss,s1,s2,s:string;<br> i,iValue:integer;<br>begin<br> iValue:=strtoint(Edit1.Text);s:='';<br> ss:=inttostr(iValue);<br> if iValue>20 then begin<br> s1:=ss[1];s2:=ss[2];<br> s:=tochina(strtoint(s1))+'十'+tochina(strtoint(s2));<br> end else if iValue=20 then<br> s:='二十'<br> else if iValue>10 then begin<br> s1:=ss[1];s2:=ss[2];<br> s:='十'+tochina(strtoint(s2))<br> end else if iValue=10 then<br> s:='十'<br> else begin<br> s:=tochina(strtoint(ss));<br> end;<br> showmessage(s);<br>end;<br>你把Button1Click和Button2Click改成函数就可以了
年:<br>function tochina(num:integer) char;<br>begin<br> case num of<br> 0:<br>result:='0';<br> 1:<br>result:='一';<br> 2:<br>result:='二';<br> 3:<br>result:='三';<br> 4:<br>result:='四';<br> 5:<br>result:='五';<br> 6:<br>result:='六';<br> 7:<br>result:='七';<br> 8:<br>result:='八';<br> 9:<br>result:='九';<br> end;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var ss,s:string;<br> i,iValue:integer;<br>begin<br> iValue:=2006;s:='';<br> for i:=1 to length(inttostr(iValue)) do begin<br> ss:=inttostr(iValue);<br> s:=s+tochina(strtoint(ss));<br> end;<br> showmessage(s);<br>end;<br>月、日:<br>procedure TForm1.Button2Click(Sender: TObject);<br>var ss,s1,s2,s:string;<br> i,iValue:integer;<br>begin<br> iValue:=strtoint(Edit1.Text);s:='';<br> ss:=inttostr(iValue);<br> if iValue>20 then begin<br> s1:=ss[1];s2:=ss[2];<br> s:=tochina(strtoint(s1))+'十'+tochina(strtoint(s2));<br> end else if iValue=20 then<br> s:='二十'<br> else if iValue>10 then begin<br> s1:=ss[1];s2:=ss[2];<br> s:='十'+tochina(strtoint(s2))<br> end else if iValue=10 then<br> s:='十'<br> else begin<br> s:=tochina(strtoint(ss));<br> end;<br> showmessage(s);<br>end;<br>你把Button1Click和Button2Click改成函数就可以了
Z zhongq14 Unregistered / Unconfirmed GUEST, unregistred user! 2006-08-18 #4 函数tochina用数组来处理更简单点,其他OK