User Tools

Site Tools


development:vbs:random_string

Random string

Function RndStr( ByVal intLen )
    Dim tmp
    Dim intRnd
	Const constCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#%&/()=?*+'\<>;:_,.-"
    Randomize
	intRnd=Len(constCHARS)+1
    For i = 1 to intLen
		do until intRnd<Len(constCHARS)+1 and intRnd>0
			intRnd = int(Rnd*100)
		loop
		tmp = tmp & Mid( constCHARS, intRnd ,1 )
		intRnd=Len(constCHARS)+1
    Next
    RndStr = tmp
End Function

Usage

WScript.echo RndStr(16)
development/vbs/random_string.txt · Last modified: 2017/08/10 10:59 (external edit)