求只能输入1-9之间的不重复数字且数字之间以英文逗号隔开的VBS写法

popnew 2003-08-23 12:01:13
求只能输入1-9之间的不重复数字且数字之间以英文逗号隔开的VBS写法
...全文
82 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
超级大笨狼 2004-01-19
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/2674/2674517.xml?temp=.1492426
超级大笨狼 2004-01-18
  • 打赏
  • 举报
回复
<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
D.Add cstr(N),cstr(N)
end if
loop
for each K in D.Keys
S=S & K & " "
next
msgbox replace(trim(S)," ",",")
</SCRIPT>
超级大笨狼 2004-01-18
  • 打赏
  • 举报
回复
<SCRIPT LANGUAGE=vbscript >
Dim N,S,D
Set D = CreateObject("Scripting.Dictionary")
do while D.Count<9
Randomize
N=Int(9 * 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>
chnj1981 2004-01-18
  • 打赏
  • 举报
回复
收藏!
超级大笨狼 2004-01-18
  • 打赏
  • 举报
回复
把我洗牌的算法52换成9
<>换成“,”就可以了
超级大笨狼 2004-01-18
  • 打赏
  • 举报
回复
洗牌完美版:
<SCRIPT LANGUAGE=vbscript >
function xipai(mystr)
xipai=""
if len(mystr)=0 then'如果是空的,那么初试化一付连续的牌
for i=1 to 52
mystr=mystr & "<" & i & "> "
next
end if
dim i,x
for i=1 to 52
myarry=split(mystr) 'myarry是下标52的数组,前0-51个有效
randomize
x=cint(rnd*(ubound(myarry)-1))'前0-51个随便找一个
mystr=replace(mystr, myarry(x) & space(1),"")'从没发的牌中随便挑一张
xipai=xipai & myarry(x) & space(1)
next
end function

function XP(n)
mystr="xipai("""")"
dim i
for i=1 to n
mystr="xipai(" & mystr & ")"
next
XP=eval(mystr)
end function
document.write "洗牌完美版" & "<br/>"
document.write "洗一次牌:" & XP(1) & "<br/>"
document.write "洗两次牌:" & XP(2) & "<br/>"
document.write "洗三次牌:" & XP(3) & "<br/>"
document.write "洗一百次牌:" & XP(100) & "<br/>"
</SCRIPT>
超级大笨狼 2004-01-18
  • 打赏
  • 举报
回复

<script language=vbs>
'功能:从很多字串中排除相同字串
'输入:很多字串组成的数组:
dim A,B
A=array("字串1","字串2","字串3","字串1","字串2","字串1","字串4")
'输出:
B=F(A)
'显示结果:B=array("字串1","字串2","字串3","字串4")
for each bbb in B
document.write bbb & "<br/>"
next

'函数部分
function F(x)'这里x是形参
dim S,D
Set D = CreateObject("Scripting.Dictionary")
for each xxx in x
if not d.Exists(xxx) then D.Add xxx,xxx
next
for each key in D.Keys
S=S & key & " "
next
set D=nothing
F=split(trim(S))
end function
</script>

popnew 2003-08-24
  • 打赏
  • 举报
回复
顶!
niaoked 2003-08-23
  • 打赏
  • 举报
回复
<form name="***" method="***" action="***">

<tr><td>please enter:</td></tr><input type=text name=text1>
<%
dim strf
dim n
dim i
dim lenf
dim flag
n=0
strf=request("text1")
'决断“,”是不是符合要求
strf=split(strf,",")
for i=lbound(strf) to ubound(strf)
if isnumber '看是不是数字,不用我说吧? then ****
n=n+2
lenf=len(strf(i))
if lenf=n then
 if ****
****用MID函数看是不是两两相等,不用我说了吧?
end if
flag=true
else
flag=false
end if
if n>=ubound(strf) then exit do
next
if flag=true then response.write"right"'判断为正确的输入
 if flag=false then response.write"false"

%>
popnew 2003-08-23
  • 打赏
  • 举报
回复
ding
popnew 2003-08-23
  • 打赏
  • 举报
回复
判断中间以逗号相隔 有点麻烦!
最好用正则表达式 JS写法也行
cloudchen 2003-08-23
  • 打赏
  • 举报
回复
isnumeric()
允许数字、负号、正号、逗号、句号
判断为true后,如果还要去除不要的内容replace掉
popnew 2003-08-23
  • 打赏
  • 举报
回复
返回函数的写法!

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧