0

The intention of this string is to generate a random number in this format: l = letter n = num,

LLNNN

Instead, it gives me this:

NN

Or sometimes:

N

Code

Local $destination = "C:\Users\Ryan\Pictures\Aurora.jpg"

If Random() < 1 Then
    $Lettera = Chr(Random(Asc("A"), Asc("Z")))
Endif
If Random() < 1 Then
    $Letterb = Chr(Random(Asc("A"), Asc("Z")))
Endif
If Random() < 1 Then
    $Numbera = Chr(Random(48, 57, 1))
Endif
If Random() < 1 Then
    $Numberb = Chr(Random(48, 57, 1))
Endif
If Random() < 1 Then
    $Numberc = Chr(Random(48, 57, 1))
Endif

SplashImageOn("Splash", $destination, 312, 146, 450, 300, 1)
Sleep(9000)
SplashOff()
If MsgBox(1, "code generator", "Create a new key?") = 1 Then
    msgBox(0, "code generator", "Your registry is:" + $Lettera + $Letterb + $Numbera + $Numberb + $Numberc)
EndIf
4

1 回答 1

0

You could assign everything as a string value and then append it all at the end.

Local $destination = "C:\Users\Ryan\Pictures\Aurora.jpg"

If Random() < 1 Then
    $Lettera = Chr(Random(Asc("A"), Asc("Z")))
Endif
If Random() < 1 Then
    $Letterb = Chr(Random(Asc("A"), Asc("Z")))
Endif
If Random() < 1 Then
    $Numbera = Chr(Random("48", "57", "1"))
Endif
If Random() < 1 Then
    $Numberb = Chr(Random("48", "57", "1"))
Endif
If Random() < 1 Then
    $Numberc = Chr(Random("48", "57", "1"))
Endif

SplashImageOn("Splash", $destination, 312, 146, 450, 300, 1)
Sleep(9000)
SplashOff()
If MsgBox(1, "code generator", "Create a new key?") = 1 Then
    msgBox(0, "code generator", "Your registry is:" & $Lettera & $Letterb & $Numbera & $Numberb & $Numberc)
EndIf
于 2013-08-15T19:19:17.753 回答