Say I have a number string like "853517".
I would like to randomize this string and come up with a completely different 6 digit number.
Please don't ask me to post what I've done so far because I have no clue where or how to start. :sick:
Printable View
Say I have a number string like "853517".
I would like to randomize this string and come up with a completely different 6 digit number.
Please don't ask me to post what I've done so far because I have no clue where or how to start. :sick:
i just wrote this one, hope it meets your needs. if anyone has a smaller or faster version, feel free to post it.
Code:Option Explicit
Private Sub Form_Load()
Dim St As String
St = "853517"
MsgBox RandomizeString(St)
End Sub
Private Function RandomizeString(ByVal MyString As String) As String
Dim i As Long
Dim Ran As Long
Dim NewString As String
Dim Ln As Long
Randomize
Ln = Len(MyString) 'i used a variable to simplify having to call this repeatedly
NewString = Space$(Ln) 'make a buffer to store the new string
For i = Ln To 1 Step -1
Ran = Int(i * Rnd) + 1 'return a random position
Mid$(NewString, Ln - i + 1, 1) = Mid$(MyString, Ran, 1)
Mid$(MyString, Ran, 1) = Mid$(MyString, i, 1)
Next i
RandomizeString = NewString
End Function