Hello! I'm trying to create an 8-character string of completely random hex numbers using the current time and date of the computer...down to the millisecond. How is this possible with VBscript?
Here's my current code, and it does work sort of, but it's not completely random, and the results can range from between 1 and 9 characters, not always hex. Any help would be GREATLY appreciated!
-----------------
set oshell=CreateObject("Wscript.Shell")
set objFSO=CreateObject("Scripting.FileSystemObject")
logfile="results.csv"
if objfso.fileexists(logfile) then
objfso.deletefile logfile
end if
Set ofile=objFSO.CreateTextFile(logfile,True)
startime=Second(Now)
Do Until second(now)-startime >=3
strdate=Day(Now)&Hour(Now)&Minute(Now)&Second(Now)&Right(Timer(),3)
Randomize
MyNumber = Int(rnd() * strdate)
ofile.write Hex(mynumber)&vbcrlf
Loop
---------------------
As you can see, I only have it run for three seconds to get an adequate cross-section to test for duplicates in Excel. Once this is completed, the file-creation portion of the code will be removed and this will need to create a random string of 8 characters, always in Hex format, to be used as a machine name (using a custom build CD for our company).
Thanks again, for any help anyone can provide!
Here's my current code, and it does work sort of, but it's not completely random, and the results can range from between 1 and 9 characters, not always hex. Any help would be GREATLY appreciated!
-----------------
set oshell=CreateObject("Wscript.Shell")
set objFSO=CreateObject("Scripting.FileSystemObject")
logfile="results.csv"
if objfso.fileexists(logfile) then
objfso.deletefile logfile
end if
Set ofile=objFSO.CreateTextFile(logfile,True)
startime=Second(Now)
Do Until second(now)-startime >=3
strdate=Day(Now)&Hour(Now)&Minute(Now)&Second(Now)&Right(Timer(),3)
Randomize
MyNumber = Int(rnd() * strdate)
ofile.write Hex(mynumber)&vbcrlf
Loop
---------------------
As you can see, I only have it run for three seconds to get an adequate cross-section to test for duplicates in Excel. Once this is completed, the file-creation portion of the code will be removed and this will need to create a random string of 8 characters, always in Hex format, to be used as a machine name (using a custom build CD for our company).
Thanks again, for any help anyone can provide!