<SCRIPT LANGUAGE=vbscript >
'洗牌
Dim N,S,D,P
P=54'牌的数量
Set D = CreateObject("Scripting.Dictionary")
do while D.Count<P
Randomize
N=Int(P * Rnd + 1)
if not D.Exists(cstr(N)) then
D.Add cstr(N),cstr(N)
end if
loop
for each K in D.Keys
S=S & K & " "
next
msgbox replace(trim(S)," ",",")
</SCRIPT>
access
select top 5 * from [table] order by rnd(id)
sql server
select top 5 * from [table] order by newid()
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Random r = new Random();
DateTime dt = new DateTime();
int month = r.Next(1, 6);
int day;
do
{
if ((month == 1) || (month == 3) || (month == 5))
day = r.Next(1, 31);
else if (month != 2)
day = r.Next(1, 30);
else
day = r.Next(1, 28);