Lỗi subscript out of range khi dùng main cad2007
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support. Subscript out of range (Error 9)
In this articleElements of and members of can only be accessed within their defined ranges. This error has the following causes and solutions:
For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh). Note Interested in developing solutions that extend the Office experience across multiple platforms? Check out the new Office Add-ins model. Office Add-ins have a small footprint compared to VSTO Add-ins and solutions, and you can build them by using almost any web programming technology, such as HTML5, JavaScript, CSS3, and XML. Support and feedbackHave questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback. I'm having trouble with the following code. In line 10 I get a 'Subscript out of range' error on intPoints(2). I followed the IntersectWith code example in the help file but don't see where mine should operate any different than theirs. They dimmed intPoints as Variant and so did I. They then extracted point info from the variable (intPoints(j)) and so did I (intPoints(2)). Yet I get the error. And the variable LinLen always remains empty. What am I doing wrong? bc Sub Intersect() 'This code is supposed to find the intersection point between 'a line and a 3dFace, check the length of the line stretched 'to that point then find an area based on that length. Dim msg As String Dim ssetObj1 As AcadSelectionSet Dim ssetObj2 As AcadSelectionSet Set ssetObj1 = ThisDrawing.SelectionSets.Add("TopLines") Set ssetObj2 = ThisDrawing.SelectionSets.Add("TopFaces") 'the following selections are made en masse, ie not in any particular order 'there are approx. 3600 lines and 16 3dFaces msg = MsgBox("Select on screen all the TOP lines.", vbOKOnly) ssetObj1.SelectOnScreen msg = MsgBox("Select on screen all the TOP faces.", vbOKOnly) ssetObj2.SelectOnScreen Dim LinLen As Variant Dim intPoints As Variant Dim TopArea As Variant Dim Area As Variant Dim entTopLine As AcadLine Dim entTopFace As Acad3DFace 'each of the 3600 lines are tested for intersection with a 3dFace For Each entTopLine In ssetObj1 'the 3dFaces are cycled thru to check for intersection with line For Each entTopFace In ssetObj2 On Error Resume Next intPoints = entTopLine.IntersectWith(entTopFace, acExtendThisEntity) 10 LinLen = intPoints(2) - 10 'error occurs here Area = LinLen * 0.25 TopArea = TopArea + Area Next Next ssetObj1.Delete ssetObj2.Delete End Sub |