Arrays 从数组中获取随机项
我从以下基本代码示例开始:Arrays 从数组中获取随机项,arrays,asp-classic,Arrays,Asp Classic,我从以下基本代码示例开始: <% block1 = "tree, ball, cheese, rabbit, waffle, planet, string, cat, dog, hole, hobbit, sing," wordArray1 = split(block1, ",") For Each item In wordArray1 Response.Write(item & "<br />") Next max=11 min = 1 Randomiz
<%
block1 = "tree, ball, cheese, rabbit, waffle, planet, string, cat, dog, hole, hobbit, sing,"
wordArray1 = split(block1, ",")
For Each item In wordArray1
Response.Write(item & "<br />")
Next
max=11
min = 1
Randomize
rand1 = Int((max-min+1)*Rnd+min)
response.write "<hr/>rand1: " & rand1 & "<hr/>"
w1 = wordArray1(0,rand1)
response.write "w1: " & w1 & "<hr/>"
%>
如何随机访问其中一个阵列
谢谢您没有创建多维数组,因此不应该传入两个参数。更改此行:
w1 = wordArray1(0,rand1)
为此:
w1 = wordArray1(rand1)
w1 = wordArray1(0,rand1)
w1 = wordArray1(rand1)