几何尺寸与公差论坛

 找回密码
 注册
查看: 752|回复: 0

【转帖】subscript out of range error 9

[复制链接]
发表于 2009-4-13 14:41:26 | 显示全部楼层 |阅读模式
subscript out of range error 9
hii there,
in vba i declared an array dim x1(0 to 10) as variant
and now am trying to assign a value to x1(0) = 0
its showing me the following error:
subscript out of rnage error 9
any suggestions
thx
vishal patel
not sure why that would be an issue but why are you bothering declaring it that way when dim x1(10) would do exactly the same thing with less typing.
bare in mind x1(10) gives an array of 11 items (zero-based), and to check your array range just debug the program and step through the code after you declare it and add a watch to see what size it is
also, check that your code does not have the option base set to 1 instead of 0 as this will start arrays at 1 not 0 hence out of range. to be on the safe side you can place the following line at the top of your code to set the base to zero:
option base 0
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-22 22:47 , Processed in 0.034817 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表