How to use the random() function??

When I use the random() function in my program,I get the same num when I run the program. How can I do if I want get differnet number?How to clean the memory?Please help me,thanks.
li_fangAsked:
Who is Participating?
 
intheConnect With a Mentor Commented:
hi,
here an example:

function Generate(s:string): string;
var
i: integer;
begin
randSeed:= 1234;
for i := 1 to length(s) do
s[i] := chr(ord(s[i]) + random(26));
Result:= s;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
edit1.text := generate(edit1.text);
end;

does that help
Regards Barry
0
 
bryan7Commented:
you can use the timer for RandSeed that way you'll always get random values
0
 
li_fangAuthor Commented:
hi,
thanks very much,you give me a good advise,I capture the time and get the random num,thanks for your help!
0
 
bryan7Commented:
glad that I can still help someone.. it's difficult, having so good experts here..
0
All Courses

From novice to tech pro — start learning today.