title: delphi generate random PIN code
body: <p>I want to generate random number with specified length.</p>
  
  <pre><code>function _RandomCode(const CodeLen: Word): Word;
  begin
    Result := Random(CodeLen);
    repeat
      Result := Result + Random(CodeLen) + 1;
    until (Length(IntToStr(Result)) = CodeLen)
  end;
  </code></pre>
  
  <p>The result always <code>10000</code></p>