Method #1:
Set objRandm = CreateObject("Scriptlet.TypeLib")
strGUID = objRandm.Guid
Msgbox strGUID
Method #2:
This method is as same as previous one, but length of the string is shorter.
Set oGuid=DotNetFactory.CreateInstance("System.Guid","mscorlib")
Set oConvert=DotNetFactory.CreateInstance("System.Convert","mscorlib")
temp= oConvert.ToBase64String(oGuid.NewGuid().ToByteArray())
temp=Left(temp,22)
temp=Replace(temp,"/", "_")
strRandm=Replace(temp,"+", "-")
Msgbox strRandm
Method #3:
The above code generates semi-unique random strings.
Msgbox hex(( ( (timer+rnd(1)) *100) + int(rnd(1)*16)*&hf0000 ) mod &h100000 )
No comments:
Post a Comment