Jump to content

Recommended Posts

Posted

I added the random password part but it's getting an error. I don't know what's wrong with it.

Button code:

Case $msg = $T_Pass
        _randStr()

Function code:

Func _randStr($len)
    $mypasschars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"
    $charArr = StringSplit($mypasschars, "")
    Local $str = ""
    For $i = 1 To $len
        $str &= $charArr[(Random(1, $charArr[0], 1))]
    Next
    Return $str
EndFunc   ;==>_randStr

Function code credit goes to Smartee.

Posted

hey donald,

The function needs to be called with a integer, that represents the length of the random string to be returned, as its sole parameter.

Here are some examples:

;MsgBox(64, "Random string", _randStr()) ;Wrong, because no parameters passed to the _randStr() function
MsgBox(64, "Random string", _randStr(12)) ;Generate a random string of length 12

$myRandomString = _randStr(10) ;Generates a random string of length 10 and stores it in a variable
MsgBox(64, "Random string stored in variable", $myRandomString)

Hope this clears things up a bit. :unsure:

-smartee

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...