Re: how to generate random string?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



You can start with something like this:

Randomize Second(Now)
Do
intEval = Int((43 * Rnd) + 48)
If intEval > 47 And intEval < 58 Then
strRetVal = strRetval & Chr(intEval)
ElseIf intEval > 64 And intEval < 91 Then
strRetVal = strRetVal & Chr(intEval)
End If

Loop Until Len(strRetVal) = 20

WScript.Echo strRetVal

http://www.dx21.com/SCRIPTING/VBSCRIPT/VIEWITEM.ASP?NTI=4&SI=7&OID=44&VL
=F&TN=Intrinsic&IDF=IID

http://www.asciitable.com/

--
Jase T. Wolfe
Dx21, LLC
http://www.Dx21.com


Jason Simmons wrote:

i need to generate a random, 20 character string that will only
contain 0-9 and A-Z

any good solutions before i start writing something inefficient?

:)
.



Relevant Pages

  • Re: how to generate random string?
    ... what is "Randomize Second" doing? ... im used to seeing simple "Randomize" to start the random number generator? ... any good solutions before i start writing something inefficient? ...
    (microsoft.public.scripting.vbscript)
  • Re: Problem with a script
    ... a loop there becomes impractical. ... You still have them as uniquely named array indexes... ... writing the code twice will only ... reading your entire code and parsing it in their head, ...
    (comp.lang.php)
  • Re: Problem with a script
    ... Okay, so variables have unique labels, that doesn't mean they still couldn't be handled in a loop. ... You still have them as uniquely named array indexes... ... I believe that for the new guy this code would be readable, and identifying problems should really not be any more difficult with this, plus I think that it actually might save some time to write the actual code from the beginnig, even though it's not at it's final stage, instead of first writing everything spread out, and then rewriting the same code again cleaned. ... If you expect a person to spend an hour reading your entire code and parsing it in their head, you wont get any help and have to solve the problem by yourself. ...
    (comp.lang.php)
  • Re: FOR Loop slows down with each iteration?
    ... >>> P.S. Don't write to a file inside a triple for loop. ... Writing to disk is generally>> done asynchronously by the operating system when the program requests to>> write one or more pages; pages were traditionally 4 K byte, but these>> days are more likely to be 16 K byte. ... All else being equal, the larger>> the more pages of data you can submit to write at one time, the less>> overhead will be involved, but only if those buffers can be pre-allocated>> ... > I cannot pre- allocate an array for the data that is being written as the> number of data is unknown...it is basically iterating through arrays and> extracting relevant data... ...
    (comp.soft-sys.matlab)
  • Re: Problem with a script
    ... a loop there becomes impractical. ... You still have them as uniquely named array indexes... ... writing the code twice will only ... reading your entire code and parsing it in their head, ...
    (comp.lang.php)