Random string-asp instance

Source: Internet
Author: User
Tags chr
The 13-digit random string generated by this instance is:
RJNVy1gcnE7F7
Source code:
<% @ LANGUAGE = VBScript %>
<Html>
<Title>
Generate 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 = 10 To 35
Char_array (I) = Chr (I + 55)
Next
'Initialize lowercase letters
For I = 36 To 61
Char_array (I) = Chr (I + 61)
Next
Randomize' initializes the random number generator.
Do while len (output) <digits
Num = char_array (Int (62-0 + 1) * Rnd + 0 ))
Output = output + num
Loop
'Set the return value
Gen_key = output
End Function
'Return the result to the browser
Response. write "the 13-digit random string generated by this instance is :"
Response. write "<center>"
Response. write gen_key (13)
Response. write "</center>"
%>
</Body>
</Html>
The following learning channels use html pages to demonstrate the actual effect of asp code. If you want to see the actual effect, copy the code preview on your own.
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.