Yes, you can use Rnd
in this case too.
Define a function getRandom()
which gives you a random string in format "XX XX XX XX" with every call.
Function getRandom() As String
Const charList = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
getRandom = _
Mid(charList, 35*Rnd+1, 1) + Mid(charList, 35*Rnd+1, 1) + " " + _
Mid(charList, 35*Rnd+1, 1) + Mid(charList, 35*Rnd+1, 1) + " " + _
Mid(charList, 35*Rnd+1, 1) + Mid(charList, 35*Rnd+1, 1) + " " + _
Mid(charList, 35*Rnd+1, 1) + Mid(charList, 35*Rnd+1, 1)
End Function
charList
is a string with all allowed characters 0-9 and A-Z.you get an random number between 1 and 36 with
35*Rnd+1
. This is your index incharList
to get randomly one of the characters.
Call the function getRandom()
in a cycle as long as you get a string which is not yet in your view.