The method of generating Chinese characters randomly by ASP

Source: Internet
Author: User
Tags binary to decimal decimal to binary end
The method of generating Chinese characters randomly by ASP

<%dim I
Dim J
Dim HS
Dim He
Dim LS
Dim LE
Dim result
Result= ""
HS = 177
he = 247
LS = 161
LE = 254
Dim max_num
max_num=65536
Randomize
For i = 1 to 4
Temp1=dec2bin (Int (HE-HS) * RND ()) + HS)
Temp2=dec2bin (Int ((le-ls) * RND ()) + LS)
result = result & Chr (Binarytodecimal (Temp1 & Temp2)-Max_num)

Next
Response.Write Result & ""
%>
<%
"Here is the function
''-------------------------------------------
Public Function Dec2bin (mynum) ' Decimal to binary '
Dim Loopcounter
If mynum >= 2 ^ Then
Dec2bin = "Too Big"
Exit Function
End If
Todo
If (Mynum and 2 ^ loopcounter) = 2 ^ Loopcounter Then
Dec2bin = "1" & Dec2bin
Else
Dec2bin = "0" & Dec2bin
End If
Loopcounter = Loopcounter + 1
Loop Until 2 ^ loopcounter > Mynum
End Function
''-------------------------------------------
Public Function binarytodecimal (binaryvalue) ' Binary to decimal ' conversion
' Returns the decimal equivalent of a binary number
Dim IDX
Dim tmp
Dim result
Dim digits
digits = Len (binaryvalue)
For idx = digits to 1 Step-1
TMP = Mid (Binaryvalue, IDX, 1)
If tmp = "1" Then result = result + 2 ^ (DIGITS-IDX)
Next
Binarytodecimal = result

End Function
%>



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.