randompassword.asp <% Dim i, intNum, intUpper, intLower, intRand, strPartPass, genPassword genPassword = \"\" Randomize ' 用Randomize生成随机种子. For i = 1 to 7 ' 循环7次,即创建7位随机密码. intNum = Int(10 * Rnd + 48) ' 0-9的ASCII码范围是48-57. intUpper = Int(26 * Rnd + 65) ' A-Z的ASCII码范围是65-90. intLower = Int(26 * Rnd + 97) ' a-z的ASCII码范围是97-123. intRand = Int(3 * Rnd + 1) ' 对Int(3 * Rnd + 1)取整得到intRand,会有3种结果,用select case判断当前的intRand值是1,2还是3.如果是1显示数字,是2显示大写字符,是3则显示小写字符. Select Case intRand Case 1 strPartPass = Chr(intNum) ' 用Chr方法换算到对应的ASCII值. Case 2 strPartPass = Chr(intUpper) Case 3 strPartPass = Chr(intLower) End Select genPassword = genPassword & strPartPass Next randomPassword = genPassword ' 将创建的密码保存在变量randomPassword中. %> <%=\"请保存好,您的密码是:\" & randomPassword%> [1] |