主题:[讨论]代码优化的问题
我写了一个程序,其中有一段将数字转化为字母的代码:
s = Int((10 * Rnd) + 1)
Select Case s
Case Is = 1
p = "a"
Case Is = 2
p = "b"
Case Is = 3
p = "c"
Case Is = 4
p = "d"
Case Is = 5
p = "z"
Case Is = 6
p = "x"
Case Is = 7
p = "l"
Case Is = 8
p = "h"
Case Is = 9
p = "v"
Case Is = 10
p = "s"
End Select
大意是将 字符p 随机替换为几个字母,原理是:先产生1个1~10之间的随机数,在用select函数挑出要替换的字母,但是如果一次性要替换的数字过多,会导致死机现象,怎样解决?
s = Int((10 * Rnd) + 1)
Select Case s
Case Is = 1
p = "a"
Case Is = 2
p = "b"
Case Is = 3
p = "c"
Case Is = 4
p = "d"
Case Is = 5
p = "z"
Case Is = 6
p = "x"
Case Is = 7
p = "l"
Case Is = 8
p = "h"
Case Is = 9
p = "v"
Case Is = 10
p = "s"
End Select
大意是将 字符p 随机替换为几个字母,原理是:先产生1个1~10之间的随机数,在用select函数挑出要替换的字母,但是如果一次性要替换的数字过多,会导致死机现象,怎样解决?