ASP random functions without repeated numbers, array implementation, and applied to the random display record set by shawl. Qiu

Source: Internet
Author: User

ASP random functions without repeated numbers, array implementation, and applied to the random display record set by shawl. Qiu

Purpose:
This function is applicable to the random display of small numbers without duplicates.
This function is applicable to displaying a small number of random non-repeated record sets.
We do not recommend that you use this function to limit the efficiency by more than one thousand.

Shawl. Qiu
2006-09-06
Http://blog.csdn.net/btbtd

Main Content: 100 records are randomly displayed for functions and application functions

    Linenum

  1. <%
  2. Dim RS, rnum
  3. Dim temp
  4. Set rs = Createobject ("ADODB. recordset ")
  5. Rs. Open "select Top 100 * From rnd_v1", Conn, 1
  6. Rnum = Rs. recordCount-1
  7. For each temp in frndnorpt (0, rnum)
  8. Rs. Move temp
  9. Response. Write RS ("sbcat ")
  10. Response. Write "<br/>"
  11. Rs. movefirst
  12. Next
  13. Rs. Close
  14. Set rs = nothing 'shawl. Qiu Code'
  15. Function frndnorpt (lwnum, upnum)
  16. '''''''''''''''''''''''''''''''''''''''' ''''
  17. 'Asp random functions without repeated numbers, array implementation, by shawl. Qiu
  18. '2006-09-06
  19. 'Http://blog.csdn.net/btbtd
  20. '''''''''''''''''''''''''''''''''
  21. 'Note: the random number exceeds 1000. This function is not recommended.
  22. '''''''''''''''''''''''''''''''''
  23. 'Parameter description:
  24. '''''''''''''''''''''''''''''''''
  25. 'Lwnum is the lower limit of the number array, for example, 1
  26. 'Upnum is the upper limit of the number array, for example, 100.
  27. '''''''''''''''''''''''''''''''''
  28. 'Sample call:
  29. '''''''''''''''''''''''''''''''''
  30. 'Dim t
  31. 'For each t in frndnorpt (1,100)
  32. 'Response. Write T & "<br/>"
  33. 'Next
  34. '''''''''''''''''''''''''''''''''''''''' ''''
  35. If upnum <1 or isnull (upnum) or upnum = "" Or isnumeric (upnum) = false then exit function
  36. If lwnum <0 or isnumeric (lwnum) = false then exit function
  37. Dim num, temp
  38. Dim AR ()
  39. Redim AR (upnum)
  40. Dim J: J = 0
  41. For temp = lwnum to upnum
  42. Num = num & "." & temp &"."
  43. Next
  44. Randomize
  45. Do until num = ""
  46. Temp = int (upnum-lwnum + 1) * RND + lwnum)
  47. If instr (Num, "." & temp & ".") <> 0 then
  48. Num = Replace (Num, "." & temp &".","")
  49. AR (j) = temp
  50. J = J + 1
  51. End if
  52. Loop
  53. Frndnorpt = ar
  54. Erase ar
  55. End function 'awl. Qiu Code'
  56. Response. Write "<p/> use the random number function to display random numbers between 1 and 100. 1: <br/> --------------------- <br/>"
  57. For each temp in frndnorpt (1,100)
  58. Response. Write temp & "<br/>"
  59. Next
  60. Response. Write "<p/> use the random number function to display random numbers between 1 and 100. 2: <br/> --------------------- <br/>"
  61. Temp = join (frndnorpt (1,100 ),"-")
  62. Response. Write mid (temp, 1, Len (temp)-1)
  63. %>


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.