|
-
Sep 4th, 2003, 10:23 AM
#1
Thread Starter
New Member
Rnd [-1] : what is this ?
I have find (in Excel VBA listing) this line:
Rnd [-1]
without other operators. It work well without error, but what it does? I know
a = Rnd (-1)
but I don't know what
Rnd [-1]
means. Can you help me?
Thanks in advance.
Last edited by raoul; Sep 5th, 2003 at 05:57 AM.
-
Sep 12th, 2003, 08:48 PM
#2
Fanatic Member
Considering that it uses brackets instead of parentheses, you are probably looking at some very old code. In this case, brackets are the same as parentheses.
Passing a negative number to Rnd causes code to ignore a Randomize command that is passed a number so that a later Rnd repeats the same series of "random" numbers. The seed doesn't get reset. You can play around with this:
VB Code:
Rnd (-1)
Randomize (1)
For i = 1 To 3
Debug.Print Rnd(1)
Next
Debug.Print " "
Note that if you don't pass a number to Randomize, Rnd (-1) has no effect. Using the above code should have the same result as if you didn't have either of the lines before the For statement.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|