Available ASP no repetitive digital random function, array implementation, and applied to random display Recordset _ Application Techniques

Source: Internet
Author: User
Cloud-dwelling Community webmaster Test available ASP No repetitive digital random function, array implementation, and applied to random display recordset
Role:
This function is suitable for randomly displaying a small number of random repeat numbers
This function is useful for displaying a small number of random, distinct sets of records
In order not to affect efficiency, the upper limit is over 1000, this function is not recommended
Shawl.qiu
2006-09-06
Http://blog.csdn.net/btbtd
Main content: Functions and application functions randomly display 100 records
LineNum
Copy Code code as follows:

<%
Dim rs, Rnum
Dim temp
Set Rs=createobject ("Adodb.recordset")
Rs.Open "SELECT top * from Rnd_v1", conn,1
Rnum=rs.recordcount-1
For each temp in frndnorpt (0,rnum)
Rs.move Temp
Response.Write rs ("Sbcat")
Response.Write "<br/>"
Rs.movefirst
Next
Rs.close
Set rs=nothing ' Shawl.qiu code '
function Frndnorpt (lwnum,upnum)
''''''''''''''''''''''''''''''''''''''''''''
' ASP no repetitive digital random function, array implementation, by Shawl.qiu
' 2006-09-06
' HTTP://BLOG.CSDN.NET/BTBTD
'''''''''''''''''''''''''''''''''
' Note: More than 1000 random numbers are not recommended for use in this function.
'''''''''''''''''''''''''''''''''
' Parameter description:
'''''''''''''''''''''''''''''''''
' Lwnum is the lower limit of the number array, such as: 1
' Upnum is the upper limit of the number array, such as: 100
'''''''''''''''''''''''''''''''''
' Sample call:
'''''''''''''''''''''''''''''''''
' Dim t
' For each T in Frndnorpt (1,100)
' Response.Write t& ' <br/> '
' Next
''''''''''''''''''''''''''''''''''''''''''''
If Upnum<1 or IsNull (upnum) or upnum= "" or IsNumeric (upnum) =false then Exit function
If Lwnum<0 or IsNumeric (lwnum) =false then Exit function
Dim num, Temp
Dim ar ()
ReDim ar (Upnum)
Dim j:j=0
For Temp=lwnum to Upnum
num=num& "." &temp& "."
Next
Randomize
Do Until num= ""
Temp=int ((upnum-lwnum+1) *rnd+lwnum)
If INSTR (num, "." &temp& ".") <>0 Then
Num=replace (num, ".") &temp& ".", "" ")
AR (j) =temp
J=j+1
End If
Loop
Frndnorpt=ar
Erase AR
End Function ' Shawl.qiu code '
Response.Write "<p/> use random number function to display 1 to 100 1:<br/>-----------------------<br/>"
For each temp in frndnorpt (1,100)
Response.Write temp& "<br/>"
Next
Response.Write "<p/> use random number function to display 1 to 100 2:<br/>-----------------------<br/>"
Temp=join (Frndnorpt (1,100), "-")
Response.Write Mid (Temp,1,len (temp)-1)
%>
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.