LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Random generation.

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


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
random letter generation Ann Excel Worksheet Functions 5 May 30th 08 06:52 PM
Random Name Generation Fleone Excel Programming 5 April 26th 06 09:18 PM
Random Name Generation pkbro Excel Worksheet Functions 1 June 21st 05 02:03 AM
Random Generation lordofthe9 Excel Programming 5 May 5th 05 03:58 PM
random number generation nyn04[_5_] Excel Programming 3 September 22nd 04 02:13 PM


All times are GMT +1. The time now is 08:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"