【发布时间】:2015-05-01 09:23:53
【问题描述】:
我有这段代码,它将每个 for 循环迭代结果输出到一个消息框:
dim str
str = inputbox("Please enter character string for encryption","Encryption")
for i=1 to len(str)
wscript.echo asc(mid(str,i,1)) - (i-1)
next
我想将每次迭代的结果存入一个数组,然后将整个数组内容以字符串的形式显示在消息框中。
我正在尝试这样的事情:
dim str, arr()
str = inputbox("Please enter character string for encryption","Encryption")
for i=1 to len(str)
redim preserve arr(ubound(arr)+1)
arr(ubound(arr)) = asc(mid(str,i,1)) - (i-1)
next
wscript.echo arr
但得到第 6 行:错误: 下标超出范围'ubound'。在将它映射到数组之前,我应该通过函数调用迭代吗?
【问题讨论】: