asp.net生成6位随机码
asp.net的6位随机码代码
C#代码
<%@ Page Language="C#" %>
<%
//----------------------- 随机密码开始 ---------------------------
ArrayList MyArray = new ArrayList();
Random random = new Random();
string str = null;
//循环的次数
int Nums = 6;
while (Nums > 0)
{
int i = random.Next(1, 9);
// if (!MyArray.Contains(i))
// {
if (MyArray.Count < 6)
{
MyArray.Add(i);
}
// }
Nums -= 1;
}
for (int j = 0; j <= MyArray.Count - 1; j++)
{
str += MyArray[j].ToString();
}
//----------------------- 随机密码结束 ---------------------------
Response.Write(str + " my array count --> " + MyArray.Count);
%>
<%@ Page Language="C#" %>
<%
//----------------------- 随机密码开始 ---------------------------
ArrayList MyArray = new ArrayList();
Random random = new Random();
string str = null;
//循环的次数
int Nums = 6;
while (Nums > 0)
{
int i = random.Next(1, 9);
// if (!MyArray.Contains(i))
// {
if (MyArray.Count < 6)
{
MyArray.Add(i);
}
// }
Nums -= 1;
}
for (int j = 0; j <= MyArray.Count - 1; j++)
{
str += MyArray[j].ToString();
}
//----------------------- 随机密码结束 ---------------------------
Response.Write(str + " my array count --> " + MyArray.Count);
%>
asp的6位随机数字的代码
Asp代码
<%
'----------------------- 随机密码开始 ---------------------------
Randomize
FreeMember=Int((999999 * Rnd) + 1) '方法1
Function makePassword(maxLen) '方法2,生成的随机码包含字母
Dim strNewPass
Dim whatsNext, upper, lower, intCounter
Randomize
For intCounter = 1 To maxLen
whatsNext = Int((1 - 0 + 1) * Rnd + 0)
If whatsNext = 0 Then
'character
upper = 90
lower = 65
Else
upper = 57
lower = 48
End If
strNewPass = strNewPass & Chr(Int((upper - lower + 1) * Rnd + lower))
Next
makePassword = strNewPass &
补充:Web开发 , ASP.Net ,