Random string-ASP instance

Source: Internet
Author: User
Tags chr return
Random | string | random | String The 13-bit random string This instance generates is: Rjnvy1gcne7f7

Source:

<%@ LANGUAGE = VBScript%>
<title>
Generate a random string
</title>
<body>
<%
Function Gen_key (digits)
' Define and initialize the array
Dim Char_array (80)
' Initialize the number
For i = 0 to 9
Char_array (i) = CStr (i)
Next
' Initialize uppercase letters
For i = ten to 35
Char_array (i) = Chr (i + 55)
Next
' Initialize lowercase letters
For i = 61
Char_array (i) = CHR (i + 61)
Next
Randomize ' Initializes a random number generator.
Do While Len (output) < digits
num = Char_array (Int (62-0 + 1) * Rnd + 0))
Output = output + num
Loop
' Set return value
Gen_key = output
End Function
' Return the results to the browser
Response.Write "The 13-bit random string generated by this instance is:"
Response.Write "<center>"
Response.Write Gen_key (13)
Response.Write "</center>"
%>
</body>

Because the next learning Channel is used are HTML pages do not normally demonstrate the actual effect of ASP code, if you want to see the actual effect, please copy the code preview.



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.