Asp.net generates 6-bit random Codes

Source: Internet
Author: User

Asp.net 6-bit random code

 

C # code
<% @ Page Language = "C #" %>
 
<%
// ----------------------- Random password start ---------------------------
ArrayList MyArray = new ArrayList ();
Random random = new Random ();
String str = null;
 
 
// Number of cycles
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 ();
}
// ----------------------- End of random password ---------------------------
Response. Write (str + "my array count -->" + MyArray. Count );
 
%>

<% @ Page Language = "C #" %>

<%
// ----------------------- Random password start ---------------------------
ArrayList MyArray = new ArrayList ();
Random random = new Random ();
String str = null;


// Number of cycles
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 ();
}
// ----------------------- End of random password ---------------------------
Response. Write (str + "my array count -->" + MyArray. Count );

%>

Code of 6-digit random numbers in asp

 

 

Asp code
<%
'----------------------- Random password start ---------------------------
Randomize
FreeMember = Int (999999 * Rnd) + 1) 'method 1


Function makePassword (maxLen) 'method 2, the generated Random Code contains letters
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
End Function
'Freember = makePassword (6)
'----------------------- Random password termination ---------------------------
 
FreeMember = int (999999-100000 + 1) * RND + 100000) 'method 3

Response. Write FreeMember & "my array count -->" & len (freember)
 
%>

 


From chenliang1234576

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.