这个是DELPHI6帮助里关于Length, IntToHex Example
原文如下:
The following example uses an edit control, a button, and a label on a form. When the button is clicked, the hexadecimal value of each character in the edit control is displayed in the label.procedure TForm1.Button1Click(Sender: TObject);var
  i: Integer;
begin
  Label1.Caption := '';
  for i := 1 to Length(Edit1.Text) do
  begin
    try
      Label1.Caption := Label1.Caption + IntToHex(Edit1.Text[i],2) + ' ';
    except
      Beep;
    end;
  end;
end;可是执行时,却出现错误,就是TRY后边那一句中的IntToHex中的参数错误,大家看看是不是DELPHI中的帮助错误。

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      i,k: Integer;
    begin
      Label1.Caption := '';
      for i := 1 to Length(Edit1.Text) do
      begin
        try
          k:=strtoint(edit1.Text[i]);
          Label1.Caption := Label1.Caption + IntToHex(k,2)+ ' ';
        except
          Beep;
        end;
      end;
    end;
    先将edit1.text[i]转成字符串。然后再转换。
      

  2.   

    Edit1的Text应当是['0'..'9']中的元素.但你这样写没什么意义.
    都是在前面加个'0',
    如'1234'变为'01020304'
      

  3.   

    leeky(雅痞·千年虫),我觉得也是,请问是DELPHI帮助中的错误吧??我不能肯定,我还以为是我什么地方弄错了