|
-
Jan 17th, 2000, 09:15 AM
#1
Thread Starter
Frenzied Member
To randomize i use this:
Randomize
MyFile = int((6 + RND) + 1)
Does this produce a pattern? My friend says yes, I say no
Steve
-
Jan 17th, 2000, 10:11 AM
#2
PowerPoster
You are both right...the Randomize statement gets a seed value from the system time, and assuming you will not be running the code on the same second of every day, it produces a different set of numbers, so they are not completely random, but near enough.
Without the randomize statement, it would produce the same set of "random" numbers every time.
Regards
------------------
- Chris
[email protected]
If it ain't broke - don't fix it 
[This message has been edited by chrisjk (edited 01-17-2000).]
-
Jan 17th, 2000, 06:32 PM
#3
Junior Member
It's just like Chris writes. Randomize uses the system time to get a "random" number. You could however write the code like this to make it more clear:
Randomize Timer
MyFile = int((6 * RND) + 1)
BTW, if you type MyFile = int((6 + RND) + 1) then MyFile will always be 7 (maybe this was a typing error?)
-
Jan 17th, 2000, 08:10 PM
#4
Guess he meant, int((6 + (RND * 10)) + 1)
------------------
Vincent van den Braken
EMail: [email protected]
ICQ: 15440110
Homepage: http://www.azzmodan.demon.nl
-
Jan 17th, 2000, 09:24 PM
#5
You could also create your own seed:
Code:
Dim Password As String
Dim Seed As Long
Dim x as Integer
Temp = Time
Seed = 0
If Mid(Temp, 2, 1) = ":" Then
Seed = Val(Mid(Temp, 1, 1)) + Val(Mid(Temp, 3, 1)) + Val(Mid(Temp, 4, 1)) + Val(Mid(Temp, 6, 1)) + Val(Mid(Temp, 7, 1))
Else
Seed = Val(Mid(Temp, 1, 1)) + Val(Mid(Temp, 2, 1)) + Val(Mid(Temp, 4, 1)) + Val(Mid(Temp, 5, 1)) + Val(Mid(Temp, 7, 1)) + Val(Mid(Temp, 8, 1))
End If
Then you could:
Code:
For x = 1 To Seed
'Your process here using the Rand function
Next x
I use this when generating truly random passwords. You can reseed anytime using the system time, and then just loop through the process the number of seed time using your random function in the loop.
------------------
Boothman
There is a war out there and it is about who controls the information, it's all about the information.
[This message has been edited by Boothman_7 (edited 01-18-2000).]
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
|