• 主页

# 请问怎样随机产生一个4位数的整数？

checkup33 2004-04-04 12:28:34

...全文
393 点赞 收藏 24

24 条回复

checkup33 2004-04-14

sxsgssgs 2004-04-05
Dim rannum
randomize
rannum=int(9000*rnd)+1000
Response.Write rannum

huhan3 2004-04-05
Dim intNum
Dim intRandomize
Randomize
Do While Len(intRandomize)<4
intNum = CStr(chr((57-48)*rnd+48))
intRandomize = intRandomize & intNum
Loop
Session("VerifySecurityCode") = intRandomize

tddw 2004-04-05

rnd 取值0-1 （不包含1)
rnd*9000 取值 0-9000(不包含9000)

(rnd*9000)+1000 取值 1000-10000(但不包含10000)

tddw 2004-04-05

(rnd*9000)+1000

angel2a 2004-04-05

fishball 2004-04-04
<%
Randomize
For i = 1 to 4
intNum1 = Int(10 * Rnd + 48)
intNum2 = Int(26 * Rnd + 65)
intNum3 = Int(26 * Rnd + 97)
intRand = Int(3 * Rnd + 1)
Select Case intRand
Case 1
strPartPass = Chr(intNum1)
Case 2
strPartPass = Chr(intNum2)
Case 3
strPartPass = Chr(intNum3)
End Select
Next
%>

pizixt 2004-04-04
randomize
rannum=int(90000*rnd)+10000

lawdoor 2004-04-04

http://www.blueidea.com/bbs/archivecontent.asp?id=1034455

jiangjiewebsky 2004-04-04

<%
Randomize
MyValue = Int((9999 * Rnd) + 1)
response.write MyValue
%>

agang3321 2004-04-04
ycodenum=4
for i=1 to ycodenum
Randomize
ycode=ycode&Int((9*Rnd))
next

response.write ycode

hhzh426 2004-04-04
dim num
randomize
num = 0
while num <= 0.1
num = Rnd()
wend
num = round(num * 10000)

renniliao 2004-04-04
dim number
randomize
number=int(Rnd()*90000)+10000

pizixt 2004-04-04
To: pizixt(皮子)
0≤ Rnd <1

pizixt 2004-04-04
To: QQgenie(妖魔鬼怪)
0< Rnd <1

To:楼上 and 楼上's 楼上 and ...

randomize
rannum=int(9000*rnd)+1000

randomize
rannum=int(90000*rnd)+10000

pizixt(皮子)的就可以了，我的代码洗牌给你解闷儿。

<SCRIPT LANGUAGE=vbscript >
'洗牌
Dim N,S,D,P
P=52'牌的数量
Set D = CreateObject("Scripting.Dictionary")
do while D.Count<P
Randomize
N=Int(P * Rnd + 1)
if not D.Exists(cstr(N)) then
end if
loop
for each K in D.Keys
S=S & K & " "
next
msgbox replace(trim(S)," ",",")
</SCRIPT>

QQgenie 2004-04-04

rnd：0 - 1，
1000为基数

for i=1 to 100000
randomize
a = int(rnd * 8999)+1000
if a<1002 or a>9990 then response.write a&"/"
next

susan930 2004-04-04
randomize
rannum=int(10000*rnd)+1000

rannum为随机的4位整数

ASP

2.8w+

ASP即Active Server Pages，是Microsoft公司开发的服务器端脚本环境。