几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   SolidWorks二次开发 (http://www.dimcax.com/hust/forumdisplay.php?f=111)
-   -   【转帖】subscript out of range error 9 (http://www.dimcax.com/hust/showthread.php?t=5789)

yang686526 2009-04-13 02:41 PM

【转帖】subscript out of range error 9
 
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


所有的时间均为北京时间。 现在的时间是 09:53 AM.