Home > Software engineering >  Cycle repeated random number
Cycle repeated random number

Time:10-09

Abcdefghijklmnopqrstuvwxyz
 char="0123456789" 

Redim num (len (char) - 1)
For x=0 to len (char) - 1
Num (x)=right (left (char, x + 1), 1)
Next

Randomize
For x=1 to 12
STR=STR & amp; Num (Int (len (char) * Rnd))
Next

WScript. Sleep 2000
The set wshshell=CreateObject (" WScript. Shell ")
Wshshell. SendKeys STR


Checked the next run to not repeat random number, seems to want to use what are mixed, circulation, beg you greatly help

CodePudding user response:

Now that is a random number, there is the possibility of repeat, if you want to produce absolutely not repeat, there should be to store a list of random Numbers compare...

CodePudding user response:

 Randomize 
For x=1 to 12
S=num (Int (len (char) * Rnd))
If instr (s)=1 then
STR=STR & amp; S
The else
X=x - 1
End the if

Next

CodePudding user response:

This is out-of-order string, don't you call a random number,

Random number is a bit random string of 0 s and 1 s, cited above, except you can print a character encoding, and there's more "noise",

In addition, you don't what is the definition of a repeat? Within the string of characters are not allowed to repeat? Or used string can no longer use?

CodePudding user response:

reference 1st floor Topc008 response:
since this is a random number, there is the possibility of repeat, if you want to produce absolutely not repeat, there should be to store a list of random Numbers compare...


Not like that, 1/f, you run the code once, if the loop output to an array, the results may not repeat, but is the same from beginning to end,
After I checked, Randomize, because the initial seed is changeless, lead to the results are the same;
When you twice running, because the initial seed change, so the result is not the same,

, and the result that I want is a run loop output every random number is not the same, not to say totally 100%, but most or at least, thinking seems to position switch, USES the mixed algorithm,

Which can greatly help to change

CodePudding user response:

reference of123 reply: 3/f
you order the string, not a random number,

Random number is a bit random string of 0 s and 1 s, cited above, except you can print a character encoding, and there's more "noise",

In addition, you don't what is the definition of a repeat? Within the string of characters are not allowed to repeat? Or used string can no longer use?


String cannot be used in a line, many do not understand, strength searched some manage to make do

CodePudding user response:

Feel answer on the second floor

CodePudding user response:

The second floor is character within the string contains no repeat,

If you want to ensure no repeat series, the most easy to achieve is to set up the dictionary, which is to generate a new string, check in a dictionary, if it is regenerated, or join a dictionary and the output is used,

CodePudding user response:

In addition a probabilistic method, is the use of pseudorandom number generation principle,

16 - byte first generate a random number as a seed (initial value), choose a key, fixed, using DES algorithm encryption, the seeds for the grouping of DES is 8 - byte, so the encryption for 2 times, you can use the ECB mode, you can also use CBC mode,

Encryption cipher text, is the output and the input of the next encryption,

Output processing: take the left or the right of the 12 bytes, each byte value mode (more than) divided by 36 36 (0 to 35), the result of the index is your character set in the string of characters,

You can try to test, the probability of repeated should be very low,

DES and SHA - 1 is the international standard algorithm to generate pseudo random number, randomness is very good,

CodePudding user response:

Perlo
reference 4 floor response:
Quote: refer to 1st floor Topc008 response:

Now that is a random number, there is the possibility of repeat, if you want to produce absolutely not repeat, there should be to store a list of random Numbers compare...


Not like that, 1/f, you run the code once, if the loop output to an array, the results may not repeat, but is the same from beginning to end,
After I checked, Randomize, because the initial seed is changeless, lead to the results are the same;
When you twice running, because the initial seed change, so the result is not the same,

, and the result that I want is a run loop output every random number is not the same, not to say totally 100%, but most or at least, thinking seems to position switch, USES the mixed algorithm,

Which can greatly help to change the

Randomize the form call once it is ok to load

CodePudding user response:

refer to 7th floor of123 response:
2 floor is within the string does not contain repeating characters,

If you want to ensure no repeat series, the most easy to achieve is to set up the dictionary, which is to generate a new string, check in a dictionary, if it is regenerated, or join a dictionary and output using


 Function GeneratePassword (length) 
Dim p, s, I, l
S="abcdefghijklmnopqrstuvwxyz" & amp; "0123456789"
Randomize: l=Len (s)
For I=1 To length
P=p & amp; Mid (s, Int (Rnd * l + 1), 1)
Next
GeneratePassword=p
End the Function


Directly into the second floor of the basis of the error code, can be an example, and if I want to specify the randomly generated GeneratePassword digits password, such as random 4-16 scope, how to do it again

CodePudding user response:

references 9 f caozhy response:
Quote: refer to 4th floor Perlo response:

Quote: refer to 1st floor Topc008 response:

Now that is a random number, there is the possibility of repeat, if you want to produce absolutely not repeat, there should be to store a list of random Numbers compare...


Not like that, 1/f, you run the code once, if the loop output to an array, the results may not repeat, but is the same from beginning to end,
After I checked, Randomize, because the initial seed is changeless, lead to the results are the same;
When you twice running, because the initial seed change, so the result is not the same,

, and the result that I want is a run loop output every random number is not the same, not to say totally 100%, but most or at least, thinking seems to position switch, USES the mixed algorithm,

Which can greatly help to change the

It is ok to Randomize form loads call a


Do not understand, in vb even half a foot is not, now I want to make a mess in 10th floor base sequence random password, consult how to do

CodePudding user response:

Randomize deleted, write in FormLoad

CodePudding user response:

 Function GeneratePassword (Length) As String 
Dim p As String, s As a String, I As an Integer, l As Integer
S="abcdefghijklmnopqrstuvwxyz" & amp; "0123456789"
Randomize
L=Len (s)
For I=1 To Length
P=p & amp; Mid (s, Int (Rnd * l + 1), 1)
Next
GeneratePassword=p
End the Function

Private Sub Command1_Click ()
Dim n As an Integer, strPassWord As String

N=Val (Text1)
If n & lt; 4 the Or n & gt; 16 Then
Randomize
N=4 + Int (Rnd * 13)
End the If


StrPassWord=GeneratePassword (n)
The Debug. Print strPassWord

End Sub

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related