J
Joergen Bondesen
Hi NG
I have maked this Code generator.
Option Explicit
Sub CodeGen()
Dim getcode As String
Dim x As Long
Open Application.ThisWorkbook.Path & "\" _
& Date & ".txt" For Output As #1
For x = 1 To 200
getcode = CodeGenerate(32, "1234567890ABCDEF")
'// Data To file
Print #1, getcode
Next x
Close #1
'Stop
End Sub
Function CodeGenerate(qty As Long, Str As String) As String
Dim x As Long
Dim y As Long
Dim Myvalue As String
For x = 1 To Len(Str)
Dim data() As Variant
ReDim Preserve data(1 To x)
data(x) = Mid(Str, x, 1)
Next x
'// Generate
For y = 1 To qty
'// Random ?????
Randomize Date * Time '* Rnd
'// Chr
Myvalue = data(Int((Len(Str) - 1 + 1) * Rnd + 1))
'// Make CodeString
If CodeGenerate = vbNullString Then
CodeGenerate = Myvalue
Else
CodeGenerate = CodeGenerate & Myvalue
End If
Next y
End Function
when I use only Date * Time:
'// Random ?????
Randomize Date * Time
I get blocks of 8 unique lines below each other, why?
when I use Date * Time * Rnd:
'// Random ?????
Randomize Date * Time * Rnd
then I get unique lines below each other, why?
How do I get optimal Randomize within Windows/Excel?
Can I find a sort of add-in for a "better" algorithm to my Random
generation?
Best Regards
Joergen Bondesen
I have maked this Code generator.
Option Explicit
Sub CodeGen()
Dim getcode As String
Dim x As Long
Open Application.ThisWorkbook.Path & "\" _
& Date & ".txt" For Output As #1
For x = 1 To 200
getcode = CodeGenerate(32, "1234567890ABCDEF")
'// Data To file
Print #1, getcode
Next x
Close #1
'Stop
End Sub
Function CodeGenerate(qty As Long, Str As String) As String
Dim x As Long
Dim y As Long
Dim Myvalue As String
For x = 1 To Len(Str)
Dim data() As Variant
ReDim Preserve data(1 To x)
data(x) = Mid(Str, x, 1)
Next x
'// Generate
For y = 1 To qty
'// Random ?????
Randomize Date * Time '* Rnd
'// Chr
Myvalue = data(Int((Len(Str) - 1 + 1) * Rnd + 1))
'// Make CodeString
If CodeGenerate = vbNullString Then
CodeGenerate = Myvalue
Else
CodeGenerate = CodeGenerate & Myvalue
End If
Next y
End Function
when I use only Date * Time:
'// Random ?????
Randomize Date * Time
I get blocks of 8 unique lines below each other, why?
when I use Date * Time * Rnd:
'// Random ?????
Randomize Date * Time * Rnd
then I get unique lines below each other, why?
How do I get optimal Randomize within Windows/Excel?
Can I find a sort of add-in for a "better" algorithm to my Random
generation?
Best Regards
Joergen Bondesen